function Dwg2Bmp,funtion Dwg2Jpg(50)

  • 主题发起人 主题发起人 Pau1
  • 开始时间 开始时间
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
 
能改,也不用装控件,不过楼主这是VBA吧,用VB写的这段是跑不起来的
 
fei_1,是VBA,请改为delphi的代码发在这里吧,非常感谢!
 
肯定要装相应的控件才行的,而且那控件还必须提供相应的功能。直接想把这段改为Delphi是不可能的,唯有参考控件的文档重新用Delphi实现。
 
楼主想找义工呢
 

Similar threads

A
回复
0
查看
737
Andreas Hausladen
A
A
回复
0
查看
687
Andreas Hausladen
A
A
回复
0
查看
618
Andreas Hausladen
A
A
回复
2
查看
532
后退
顶部