P
Pau1
Unregistered / Unconfirmed
GUEST, unregistred user!
谁能把以下用vb写的代码改为用delphi写,并且在delphi下需要如何设置(如需要安装acad控件吗)才可以成功运行?Function Dwg2Bmp(DwgFullName As String)Dim NewDwg As AcadDocumentSet NewDwg = Documents.Open(DwgFullName)Dim DwgPath As StringDim DwgName As StringDwgPath = ThisDrawing.PathDwgName = Left(ThisDrawing.Name, (InStr(ThisDrawing.Name, ".dwg")) - 1)Dim exportFile As StringexportFile = DwgPath & "/" & DwgNameDim mode As IntegerDim corner1(0 To 2) As DoubleDim corner2(0 To 2) As DoubleDim BlockSS As AcadSelectionSetOn Error Resume NextSet BlockSS = ThisDrawing.SelectionSets("BlockSS")If Err Then Set BlockSS = ThisDrawing.SelectionSets.Add("BlockSS")BlockSS.Clearmode = acSelectionSetCrossingcorner1(0) = ThisDrawing.Limits(0): corner1(1) = ThisDrawing.Limits(1): corner1(2) = 0corner2(0) = ThisDrawing.Limits(2): corner2(1) = ThisDrawing.Limits(3): corner2(2) = 0BlockSS.Select mode, corner1, corner2ThisDrawing.Export exportFile, "bmp", BlockSSBlockSS.DeleteNewDwg.CloseSet NewDwg = NothingEnd FunctionFunction Dwg2Jpg(DwgFullName As String)Dim NewDwg As AcadDocumentSet NewDwg = Documents.Open(DwgFullName)Dim JpgName As StringJpgName = Left(DwgFullName, (InStr(DwgFullName, ".dwg")) - 1) & ".jpg"Dim plotFileName As StringplotFileName = "PublishToWeb JPG.pc3"Dim corner1(0 To 1) As DoubleDim corner2(0 To 1) As Doublecorner1(0) = ThisDrawing.Limits(0): corner1(1) = ThisDrawing.Limits(1)corner2(0) = ThisDrawing.Limits(2): corner2(1) = ThisDrawing.Limits(3)ThisDrawing.ActiveLayout.CenterPlot = TrueThisDrawing.ActiveLayout.StandardScale = acScaleToFitThisDrawing.ActiveLayout.SetWindowToPlot corner1, corner2ThisDrawing.ActiveLayout.GetWindowToPlot corner1, corner2ThisDrawing.ActiveLayout.PlotType = acWindowDim result As Booleanresult = ThisDrawing.Plot.PlotToFile(JpgName, plotFileName)NewDwg.CloseSet NewDwg = NothingEnd Function