01-20-2022
05:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-20-2022
05:26 PM
Full code below. Export face as DXF
'CREDITS: 'Code By @ClintBrown3D 'Originally posted at https://clintbrown.co.uk/dxf-export 'Mouse input code based on this forum post: https://forums.autodesk.com/t5/inventor-customization/ilogic-to-handle-mouse-event-for-part-selection/td-p/3902918 'Additonal DXF info via 'https://forums.autodesk.com/t5/inventor-customization/export-face-as-dxf-from-api/td-p/1965512 Start : Error0 = 1 On Error GoTo error1 ThisApplication.StatusBarText = "Select a Face to Export as DXF" Dim doc = ThisApplication.ActiveDocument Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face to Export as DXF") doc.SelectSet.Select(entity) Dim oFace As Face oFace = doc.SelectSet(1) If Not oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then MessageBox.Show("A planar face must be selected, the rule will exit", "Error Handling") Return End If strSBName = oFace.SurfaceBody.Name strSBNameArray = strSBName.Split("_") strSBNameArrayCount = UBound(strSBNameArray) strDefaultFileName = strSBNameArray(strSBNameArrayCount) 'gets the last element in the array SetTheFilePathHere = ThisDoc.Path SetTheFilenameHere = InputBox("Enter the file name", "Face to DXF Export",strDefaultFileName) ThisApplication.CommandManager.PostPrivateEvent(kFileNameEvent, SetTheFilePathHere &"\" & SetTheFilenameHere & ".dxf") ThisApplication.StatusBarText = "Exporting your DXF, please hold" Dim oCtrlDef As ButtonDefinition oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand") oCtrlDef.Execute Error0 = 0 MessageBox.Show("Success! - DXF exported", "Face to DXF Export") ThisApplication.StatusBarText = "Success! - DXF exported" InventorVb.DocumentUpdate(False) Q = MessageBox.Show("Select another face?", "Face to DXF Export",MessageBoxButtons.YesNo) If Q = vbYes Then GoTo Start End If error1 : If Error0 = 1 Then MessageBox.Show("iLogic Rule Cancelled", "Face to DXF Export") End If