×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

export function in R14

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

RE: export function in R14

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

"Everybody is ignorant, only on different subjects." — Will Rogers

RE: export function in R14

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'

RE: export function in R14

(OP)
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

RE: export function in R14

(OP)
I am stuck. Pls help.

RE: export function in R14

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

RE: export function in R14

(OP)
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.

RE: export function in R14

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

RE: export function in R14

(OP)
borgunit,
Thanks for your help. It works. You saved my day.
y2kmvr

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources