- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Export "DWG" select a face using a VBA macro
Can anybody help????
I have the following code that outputs an AutoCAD "Dwg" file of an extruded face. The output is a 2d profile.
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oBaseFace As Face
Set oBaseFace = oDoc.SelectSet.Item(1): THIS IS THE PROBLEM LINE!!!!
Dim Cm As CommandManager
Set Cm = ThisApplication.CommandManager
Call Cm.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent,"C:\Test.dwg")
Dim oCtrlDef As ButtonDefinition
Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")
Call oCtrlDef.Execute
It works fine but I have to pre-select the face of the extrusion manually before running the macro. Does anybody know how to automatically select the face using the VBA macro rather than manually selecting the face first?
All I am doing is creating a sketch (Lines/Arcs/Circles) then extruding the sketch. Nothing else!
Many thanks in advance!!!!
Darren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I think that you can do this without a macro, I seem to recall a right-click option to export a face.
(I am waiting for re-installation on a new PC so can't check today).
Your VBA should be able to iterate through all faces and choose one, but how will it know which one you intended to export?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
May be:
SyntaxEditor Code Snippet
Dim testFace As Face Try testFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face") Catch ex As Exception End Try If (testFace Is Nothing) Then Return End If