Creating AutoCAD DXF file by VB
Creating AutoCAD DXF file by VB
(OP)
Hi !!!!
Can anyone please tell me how to create AutoCAd compatible DXF files from Visual Basic
(sorry ...it might be a many time discussed old problem)
Shakildor
Can anyone please tell me how to create AutoCAd compatible DXF files from Visual Basic
(sorry ...it might be a many time discussed old problem)
Shakildor





RE: Creating AutoCAD DXF file by VB
DXFText = 0 & vbCrLf
DXFText = DXFText & "SECTION" & vbCrLf
DXFText = DXFText & 2 & vbCrLf
DXFText = DXFText & "ENTITIES" & vbCrLf
The last four lines are always:
DXFText = DXFText & 0 & vbCrLf
DXFText = DXFText & "ENDSEC" & vbCrLf
DXFText = DXFText & 0 & vbCrLf
DXFText = DXFText & "EOF" & vbCrLf
When DXFText is complete, create a text file and print to it like:
Open "C:\" & FileName.Text & ".Dxf" For Output As #1
Print #1, DXFText
Close #1
You need to know the group codes for AutoCAD. For instance, to do a circle, it's:
DXFText = DXFText & 0 & vbCrLf
DXFText = DXFText & "CIRCLE" & vbCrLf
DXFText = DXFText & 8 & vbCrLf
DXFText = DXFText & Layer$ & vbCrLf
DXFText = DXFText & 10 & vbCrLf
DXFText = DXFText & Round(CenterX, 4) & vbCrLf
DXFText = DXFText & 20 & vbCrLf
DXFText = DXFText & Round(CenterY, 4) & vbCrLf
DXFText = DXFText & 40 & vbCrLf
DXFText = DXFText & Round(Radius, 4) & vbCrLf
In this case, 8 preceeds the layer name, 10 preceeds the x coordinate of the circle's center, 20 preceeds the y coordinate of the circle's center and 40 preceeds the circle's redius.
Each AutoCAD entity has similar "codes" that identify it's geometric description. Find them in AutoCAD help or a book. YOu can also lear a lot by creating a dxf file in AutoCAD and reading it.
RE: Creating AutoCAD DXF file by VB
Here is where I found out the DXF syntax.
http://usa.autodesk.com/adsk/servlet/item?id=752569&siteID=123112
I made functions for simple tasks, such as WriteCircle(Dim radius as Double, Dim x as Double, Dim y as Double, Dim layer as String) etc.
-Matt
RE: Creating AutoCAD DXF file by VB
A similar approach can be used with PHP on a web site so you can take user input and send them a dxf drawing.