export function in R14
export function in R14
(OP)
Hi Everyone,
I am trying to export DXF file into STEP through VB Automation. The function/method for export does not seem to work. It is not giving any error. Please see attached code. Thanks for your help. The export function is called at the end of the program.
Private Sub Command1_Click()
Dim ACADApp As AcadApplication
'Check if the Application AutoCAD is running.
'if it is then, link to this
Set ACADApp = GetObject("", "AutoCAD.Application.16")
'Set the AutoCAD visibility to False (batch execution)
ACADApp.Visible = False
On Error Resume Next
If Err Then
Err.Clear
'If AutoCAD is not running,launch it and attach it to this process
Set ACADApp = CreateObject("AutoCAD.Application.16")
'Set the AutoCAD visibility to False (batch execution)
ACADApp.Visible = True
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
' Disply which version of AutoCAD that we are running
MsgBox "Now running " + ACADApp.Name + _
" version " + ACADApp.Version
'Open the 3D DXF file into AutoCAD
ACADApp.Application.Documents.Open ("C:\output1\Robin6h.dxf")
'Display the Active Document name
MsgBox "Active Document Name:" & ACADApp.Application.ActiveDocument.Name
'Display the full name of Active Document
MsgBox "Active Document FullName:" & ACADApp.Application.ActiveDocument.FullName
' Define the name for the exported file
Dim exportFile As String
exportFile = "C:\output\reddy1" ' Adjust path to match your system
' Create an empty selection set
Dim sset1 As AcadSelectionSet
Set sset1 = ACADApp.ActiveDocument.SelectionSets.Add("TEST1")
'Display the document name that we are going nto export into STEP
MsgBox "activedocument:" & ACADApp.ActiveDocument.FullName
' Export the current drawing to the file specified above.
ACADApp.ActiveDocument.Export exportFile, "STP", sset1
'Delete the set
sset1.Delete
'end of Export
'Quit the Application
ACADApp.Quit
End Sub
Thanks
y2kmvr
I am trying to export DXF file into STEP through VB Automation. The function/method for export does not seem to work. It is not giving any error. Please see attached code. Thanks for your help. The export function is called at the end of the program.
Private Sub Command1_Click()
Dim ACADApp As AcadApplication
'Check if the Application AutoCAD is running.
'if it is then, link to this
Set ACADApp = GetObject("", "AutoCAD.Application.16")
'Set the AutoCAD visibility to False (batch execution)
ACADApp.Visible = False
On Error Resume Next
If Err Then
Err.Clear
'If AutoCAD is not running,launch it and attach it to this process
Set ACADApp = CreateObject("AutoCAD.Application.16")
'Set the AutoCAD visibility to False (batch execution)
ACADApp.Visible = True
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
' Disply which version of AutoCAD that we are running
MsgBox "Now running " + ACADApp.Name + _
" version " + ACADApp.Version
'Open the 3D DXF file into AutoCAD
ACADApp.Application.Documents.Open ("C:\output1\Robin6h.dxf")
'Display the Active Document name
MsgBox "Active Document Name:" & ACADApp.Application.ActiveDocument.Name
'Display the full name of Active Document
MsgBox "Active Document FullName:" & ACADApp.Application.ActiveDocument.FullName
' Define the name for the exported file
Dim exportFile As String
exportFile = "C:\output\reddy1" ' Adjust path to match your system
' Create an empty selection set
Dim sset1 As AcadSelectionSet
Set sset1 = ACADApp.ActiveDocument.SelectionSets.Add("TEST1")
'Display the document name that we are going nto export into STEP
MsgBox "activedocument:" & ACADApp.ActiveDocument.FullName
' Export the current drawing to the file specified above.
ACADApp.ActiveDocument.Export exportFile, "STP", sset1
'Delete the set
sset1.Delete
'end of Export
'Quit the Application
ACADApp.Quit
End Sub
Thanks
y2kmvr





RE: export function in R14
"Everybody is ignorant, only on different subjects." — Will Rogers
RE: export function in R14
'On Error Resume Next'
is not followed by 'On Error Goto 0'
As such if an err occurs BEFORE this statement the code will screech to a halt with an err msg...
Else if an err occurs post-statement the remaining code will run its course without any err msg...
Lemme see...I'll try to give this a closer look
Mala Singh
'Dare to Imagine'
RE: export function in R14
Thanks for the quick response.
The problem I am having is :
The code
ACADApp.ActiveDocument.Export exportFile, "STP", sset1
appears to work with NO errors and does not produce any rsults. If I replace "STP" with "DWG" it works fine.
In interactive AutoCAD, the export function works fine for STEP (.stp) output.
Thanks in advance for your help.
y2kmvr
RE: export function in R14
RE: export function in R14
"Everybody is ignorant, only on different subjects." — Will Rogers
RE: export function in R14
ACADApp.ActiveDocument.Export exportFile, "STP", sset1
using SendCommand.
Any documentation/help/synatx is useful.
As always, thanks for your help.
RE: export function in R14
ACADApp.ActiveDocument.SetVariable "CMDDIA", 0
ACADApp.ActiveDocument.SendCommand "STEPOUT" & vbCr & ExportFile & vbCr & vbCr
The SendCommand just sends text streams to the command line, FYI.
"Everybody is ignorant, only on different subjects." — Will Rogers
RE: export function in R14
Thanks for your help. It works. You saved my day.
y2kmvr