Flip Face Flat Pattern

Flip Face Flat Pattern

sdijkstraJ7UYB
Explorer Explorer
475 Views
2 Replies
Message 1 of 3

Flip Face Flat Pattern

sdijkstraJ7UYB
Explorer
Explorer

Hi!

 

Currently I'm working in an assembly with only flat plates (as sheet metal parts). All SM parts are engraved on the bottom side which means all Flat patterns should be faced towards the side with engraving. This so the export to DXF is always correctly. At this moment the engraving is constantly at the wrong side for every plate so I want to Flip the FP Oriëntations, from the assembly, at once. Can somebody help me with this?

 

I already found the code from below. It should be something like this but the rule has to be runned from the upper assembly (and not from the part itself).

 

'Flip Base Face
' Set a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'ensure this part has a flat pattern
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oPartDoc.ComponentDefinition
If oSMDef.FlatPattern Is Nothing Then
'create flat pattern
oSMDef.Unfold
Else
oSMDef.FlatPattern.Edit
end if

'flip the flat pattern base face
oSMDef.FlatPattern.FlipBaseFace

'zoom all
ThisApplication.ActiveView.Fit

 

0 Likes
Accepted solutions (1)
476 Views
2 Replies
Replies (2)
Message 2 of 3

FINET_Laurent
Advisor
Advisor
Accepted solution

Hi @sdijkstraJ7UYB,

 

This code will loop through each all individual parts placed in the active assembly. It will then create a flat pattern if it doesn't already exists, and flip the base face : 

Dim doc As Inventor.AssemblyDocument = ThisApplication.ActiveDocument
Dim acd As Inventor.AssemblyComponentDefinition = doc.ComponentDefinition

For Each refDoc As Inventor.Document In doc.ReferencedDocuments
	If refDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Continue For
	If refDoc.ComponentDefinition.Type <> ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then Continue For
	
	Dim smDef As Inventor.SheetMetalComponentDefinition = refDoc.ComponentDefinition
	If smDef.FlatPattern Is Nothing Then smDef.Unfold

	smDef.FlatPattern.FlatPatternOrientations.ActiveFlatPatternOrientation.FlipBaseFace = True

Next

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 3 of 3

sdijkstraJ7UYB
Explorer
Explorer

Hi @FINET_Laurent ,

 

Thanks a lot, it works!

 

Regards, 

Sven