Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

export function in R14

Status
Not open for further replies.

y2kmvr

Aerospace
Oct 17, 2004
14
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
 
Replies continue below

Recommended for you

From my documentation, STP is not a valid export method type in AutoCAD.

"Everybody is ignorant, only on different subjects." — Will Rogers
 
From a cursory glance thru your code, I'd say the statement:

'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'
 
Hi evryone:
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
 
If the VB object model does not support that export type, you may have to resort to the SendCommand method.


"Everybody is ignorant, only on different subjects." — Will Rogers
 
What is the best way to replace this statement using SendCommand.

ACADApp.ActiveDocument.Export exportFile, "STP", sset1
using SendCommand.

Any documentation/help/synatx is useful.

As always, thanks for your help.
 
I am not quite sure how the step command works in AutoCAD (we have not purchased that add on) but if it is somewhat like IGES, it could be...

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
 
borgunit,
Thanks for your help. It works. You saved my day.
y2kmvr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor