VBA or Python code examples or demo needed
I need to build a simple script
can somebody point me to a source for examples "commands with filenames as parameter"
-generate a new drawing
-import a pdf-file by full-name
- (some magik I know)
-zoom extents
-export all to svg by fullname
Comments
-
Hello.
Something very basic would be like this:
'————————————————
Sub NewDrawing()
Dim doc As AcadDocument
Set doc = ThisDrawing.Application.Documents.Add
End Sub'————————————————
Sub ImportPDF()
Dim doc As AcadDocument
Set doc = ThisDrawing.Application.ActiveDocumentDim svFileDia As Integer
svFileDia = ThisDrawing.GetVariable("FILEDIA")ThisDrawing.SetVariable "FILEDIA", 0
Dim FileName As String
FileName = "c:/temp/vba_import.pdf"Dim Page As Integer
Page = 1Dim InsPt As String
InsPt = "0,0"Dim IScale As Double
IScale = 1Dim Rot As Double
Rot = 0ThisDrawing.SendCommand "_-pdfimport" & vbCrLf _
& "_f" & vbCrLf _
& FileName & vbCrLf _
& Page & vbCrLf _
& InsPt & vbCrLf _
& CStr(IScale) & vbCrLf _
& CStr(Rot) & vbCrLfIf svFileDia Then
ThisDrawing.SetVariable "FILEDIA", svFileDia
End IfThisDrawing.SendCommand "_zoom" & vbCrLf _
& "_e" & vbCrLfEnd Sub
'————————————————
Sub ExportSvg()
Dim svFileDia As Integer
svFileDia = ThisDrawing.GetVariable("FILEDIA")ThisDrawing.SetVariable "FILEDIA", 0
Dim SvgName As String
SvgName = "c:/temp/vba_export.svg"ThisDrawing.SendCommand "_export" & vbCrLf _
& SvgName & vbCrLfIf svFileDia Then
ThisDrawing.SetVariable "FILEDIA", svFileDia
End IfEnd Sub
'————————————————
Sub Main()
NewDrawing
ImportPDF
ExportSvg
End Sub0 -
The same can be done in lisp as well. One thing that has been asked for pdf import is about importing a page or all pages in a multi page pdf and how to arrange.
0 -
You can find some samples in:
C:\Program Files\Bricsys\BricsCAD V23 pt_BR\API
Also, I would not recommend using VB or Python. C# has a lot of content over internet.
Use the keywords: C# autocad the thing you want to do.
0