Get back to Folded Sheet Metal VBA

Get back to Folded Sheet Metal VBA

Anonymous
Not applicable
1,188 Views
1 Reply
Message 1 of 2

Get back to Folded Sheet Metal VBA

Anonymous
Not applicable

How can i get back to folded Sheet Metal Part after export of DXF file made from help API. 

Looking that for while because it is depressing clicking so much buttons for save the file.

When you want to save file you have to firstly go to folded sheet metal part. of course one popup is displayed by the time. 

 

Code from API I have already modified to save in the same folder that sheet metal file exist, can be usefull for inventor users. It also get thickness from thickness of sheet metal.

 


Public Function FilePath(ByVal fullFilename As String) As String
FilePath = Left$(fullFilename, InStrRev(fullFilename, "\"))
End Function

Public Function BaseFilename(ByVal fullFilename As String) As String
Dim temp As String
Dim lentemp As String
Dim count As Long
Dim instrtemp As Long
instrtemp = InStrRev(fullFilename, "\")
lentemp = Len(fullFilename)
count = lentemp - instrtemp
temp = Right$(fullFilename, count)
BaseFilename = Left$(temp, InStrRev(temp, ".") - 1)
End Function

Public Sub WriteSheetMetalDXF()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim fullFilename As String
fullFilename = oDoc.fullFilename()

Dim oSheetMetalCompDef As SheetMetalComponentDefinition
Set oSheetMetalCompDef = oDoc.ComponentDefinition


Dim oDataIO As DataIO
Set oDataIO = oDoc.ComponentDefinition.DataIO

' Build the string that defines the format of the DXF file.
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=Outer&InvisibleLayers=IV_Tangent;IV_Bend;IV_Bend_Down;IV_Bend_Up;IV_ARC_CENTERS;IV_FEATURE_PROFILES_DOWN;IV_FEATURE_PROFILES"

Dim oThicknessParam As Parameter
Set oThicknessParam = oSheetMetalCompDef.Thickness

Dim oThicknessString As String
oThicknessString = oThicknessParam.Value * 10

Dim dxffile As String
dxffile = FilePath(fullFilename) & BaseFilename(fullFilename) & "  thickness " & oThicknessString & "mm .dxf"


oDataIO.WriteDataToFile sOut, dxffile

MsgBox ("DXF file has been saved to: " & dxffile)

End Sub

0 Likes
Accepted solutions (1)
1,189 Views
1 Reply
Reply (1)
Message 2 of 2

MechMachineMan
Advisor
Advisor
Accepted solution
Public Function FilePath(ByVal fullFilename As String) As String
   FilePath = Left$(fullFilename, InStrRev(fullFilename, "\"))
End Function
Public Function BaseFilename(ByVal fullFilename As String) As String Dim temp As String Dim lentemp As String Dim count As Long Dim instrtemp As Long instrtemp = InStrRev(fullFilename, "\") lentemp = Len(fullFilename) count = lentemp - instrtemp temp = Right$(fullFilename, count) BaseFilename = Left$(temp, InStrRev(temp, ".") - 1) End Function
Public Sub WriteSheetMetalDXF() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim fullFilename As String fullFilename = oDoc.fullFilename() Dim oSheetMetalCompDef As SheetMetalComponentDefinition Set oSheetMetalCompDef = oDoc.ComponentDefinition Dim oDataIO As DataIO Set oDataIO = oDoc.ComponentDefinition.DataIO ' Build the string that defines the format of the DXF file. Dim sOut As String sOut = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=Outer&InvisibleLayers=IV_Tangent;IV_Bend;IV_Bend_Down;IV_Bend_Up;IV_ARC_CENTERS;IV_FEATURE_PROFILES_DOWN;IV_FEATURE_PROFILES" Dim oThicknessParam As Parameter Set oThicknessParam = oSheetMetalCompDef.Thickness Dim oThicknessString As String oThicknessString = oThicknessParam.Value * 10 Dim dxffile As String dxffile = FilePath(fullFilename) & BaseFilename(fullFilename) & " thickness " & oThicknessString & "mm .dxf"
oDataIO.WriteDataToFile sOut, dxffile
Try
oSheetMetalCompDef.FlatPattern.ExitEdit
Catch
MsgBox("Error Exitting Flat Pattern!")
End try
MsgBox ("DXF file has been saved to: " & dxffile)
End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type