Export dxf flat pattern only on Sheet Metal pattern

riccardo_ederle
Explorer
Explorer

Export dxf flat pattern only on Sheet Metal pattern

riccardo_ederle
Explorer
Explorer

Hi everybody,

 

looking for this forum I found a good iLogic rule to export DXF flat pattern from part; I customized it change something to export in dxf with layers and colors that I want; It's working very well;

 

-------------------------------------------------------

'Set your filepath here:
SETFilePath = "C:\VaultLocale"

Dim partDoc As PartDocument
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
MessageBox.Show ("Please open a part document", "iLogic")
End If

'Check for flat pattern >> create one if needed
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold

Else
oCompDef.FlatPattern.Edit
End If

'DXF Settings
Dim sOut As String
Dim sPATH As String
sOut = "FLAT PATTERN DXF?AcadVersion=2007&RebaseGeometry=True&OuterProfileLayer=0&OuterProfileLayerColor=0;0;0&InteriorProfilesLayer=0&InteriorProfilesLayerColor=0;0;0&BendProfileLayer=0&BendLayerColor=0;100;0&BendLayerLineType=37634&BendDownProfileLayer=0&BendDownLayerColor=0;255;0&BendDownLayerLineType=37634&BendUpProfileLayer=0&BendUpLayerColor=255;255;0&BendUpLayerLineType=37634&InvisibleLayers=IV_ARC_CENTERS;IV_TANGENT;IV_ROLL;IV_ROLL_TANGENT;IV_ALTREP_BACK;IV_ALTREP_FRONT;IV_FEATURE_PROFILES_DOWN;IV_FEATURE_PROFILES;IV_TOOL_CENTER_DOWN;DIGI_MARKER_TOOL_1;DIGI_MARKER_TOOL_2;IV_INNER_PROFILES;"


Dim sFname As String
sFname = SETFilePath & "\" & ThisDoc.FileName(False) & ".dxf"

'Export the DXF and fold the model back up
oCompDef.DataIO.WriteDataToFile( sOut, sFname)
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oDoc.ComponentDefinition
oSMDef.FlatPattern.ExitEdit

'ThisApplication.StatusBarText = "@ClintBrown3D: DXF saved to: " & sFname
MessageBox.Show("DXF saved to: " & sFname, "@ClintBrown3D: Success!")

 

--------------------------------------------------

 

I would like to put this rule like an external iLogic rule (I don't want set it inside the sheet metal template) and set a trigger that "before save it" launches this rule so automatically when we save an dxf export is done; 

My problem is that on trigger setting I can't make difference from solid and sheet metal part; so when I save solid part without a flat pattern a pop up errore will be display; 

 

Is there a way to put on iLogic rule to activate that rule just when I working in a sheet metal part???

 

thanks

0 Likes
Reply
150 Views
2 Replies
Replies (2)

vpeuvion
Advocate
Advocate

Hi,

Here is an example of code that allows you to check if a part is a sheet metal.

Dim oDoc As PartDocument = ThisDoc.Document
Dim sDocumentSubType As String = oDoc.SubType
If sDocumentSubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	MessageBox.Show("Is Sheet metal")
Else
	MessageBox.Show("Is Not Sheet metal")
End If

Hope this will help you.

Vincent.

 

WCrihfield
Mentor
Mentor

Hi @riccardo_ederle.  Besides just checking if it is a sheet metal part, you should also include something like a Try...Catch...End Try statement to enclose the 'Unfold' method, just in case there is not a flat pattern yet, and the folded model can not be unfolded without errors.  That will avoid the rule crashing when that error happens, and also allows you the opportunity to exit the rule without trying to export the flat pattern when the FlatPattern could not be obtained.  And, I don't think you actually need the FlatPatten to be in 'Edit Mode' when you export it.  You could just get the DataIO of the FlatPattern object itself directly, instead of from the SheetMetalComponentDefinition object, like: FlatPattern.DataIO.WriteDataToFile().

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes