Sheet Metal Flat Pattern

Sheet Metal Flat Pattern

AnthonyB7
Enthusiast Enthusiast
1,167 Views
10 Replies
Message 1 of 11

Sheet Metal Flat Pattern

AnthonyB7
Enthusiast
Enthusiast

I have a iLogic code here (See below), that I copied from on one of the forums here, for creating flat patterns from a sheet metal part template. It is working great in automatically generating a flat pattern but is there a way to update/add in the code to delete the old flat pattern and create a new one? Or Over write the other flat pattern. The reason for this is that under the code I have linked the Custom iProperties Value to the drawing. Meaning the bounding box of the flat pattern (i.e. Height and Width) are linked with the parts list.  Maybe someone can help me with this. Thank you.

 

On Error Resume Next

Dim oDoc = ThisApplication.ActiveDocument

'CHECK FILE TYPE
If oDoc.DocumentType <> kPartDocumentObject Then
	Return
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDoc.ComponentDefinition

oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

If oCompDef.HasFlatPattern Then
	Return
Else
	'CREATE FLAT PATTERN IF DOESN'T EXIST
	If oCompDef.Type = 150995200
		ThisApplication.ScreenUpdating = False 
		oCompDef.Unfold()
		ThisApplication.ScreenUpdating = True
		'oDoc.ComponentDefinition.FlatPattern.Edit()
		oCompDef.FlatPattern.ExitEdit
	End If
End If

Dim extents_length As String = SheetMetal.FlatExtentsLength
Dim extents_width As String = SheetMetal.FlatExtentsWidth

iProperties.Value("Custom", "Height") = extents_length
iProperties.Value("Custom", "Width") = extents_width

 

0 Likes
Accepted solutions (2)
1,168 Views
10 Replies
Replies (10)
Message 2 of 11

dalton98
Collaborator
Collaborator
Accepted solution

Change your code to this:

If oCompDef.HasFlatPattern Then
	oCompDef.FlatPattern.Delete
	'CREATE FLAT PATTERN IF DOESN'T EXIST
	If oCompDef.Type = 150995200
		ThisApplication.ScreenUpdating = False 
		oCompDef.Unfold()
		ThisApplication.ScreenUpdating = True
		'oDoc.ComponentDefinition.FlatPattern.Edit()
		oCompDef.FlatPattern.ExitEdit
	End If
Else
	'CREATE FLAT PATTERN IF DOESN'T EXIST
	If oCompDef.Type = 150995200
		ThisApplication.ScreenUpdating = False 
		oCompDef.Unfold()
		ThisApplication.ScreenUpdating = True
		'oDoc.ComponentDefinition.FlatPattern.Edit()
		oCompDef.FlatPattern.ExitEdit
	End If
End If
Message 3 of 11

AnthonyB7
Enthusiast
Enthusiast
Do I insert this after "" oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
0 Likes
Message 4 of 11

dalton98
Collaborator
Collaborator

Yes. Is your intention also to change every part document into a sheet metal part? bc thats what that line does.

0 Likes
Message 5 of 11

AnthonyB7
Enthusiast
Enthusiast
No, I only placed this code on sheet metal .ipt parts. So for standard parts this code does not run. So the code that I have now looks like this. (See below) What should I do to make this code only to create sheet metal flat pattern from the sheet metal template. Also link the bounding box dimensions to the custom iproperty values.

On Error Resume Next

Dim oDoc = ThisApplication.ActiveDocument

'CHECK FILE TYPE
If oDoc.DocumentType <> kPartDocumentObject Then
Return
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDoc.ComponentDefinition

oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

If oCompDef.HasFlatPattern Then
oCompDef.FlatPattern.Delete
'CREATE FLAT PATTERN IF DOESN'T EXIST
If oCompDef.Type = 150995200
ThisApplication.ScreenUpdating = False
oCompDef.Unfold()
ThisApplication.ScreenUpdating = True
'oDoc.ComponentDefinition.FlatPattern.Edit()
oCompDef.FlatPattern.ExitEdit
End If
Else
'CREATE FLAT PATTERN IF DOESN'T EXIST
If oCompDef.Type = 150995200
ThisApplication.ScreenUpdating = False
oCompDef.Unfold()
ThisApplication.ScreenUpdating = True
'oDoc.ComponentDefinition.FlatPattern.Edit()
oCompDef.FlatPattern.ExitEdit
End If
End If

Dim extents_length As String = SheetMetal.FlatExtentsLength
Dim extents_width As String = SheetMetal.FlatExtentsWidth

iProperties.Value("Custom", "Height") = extents_length
iProperties.Value("Custom", "Width") = extents_width

0 Likes
Message 6 of 11

dalton98
Collaborator
Collaborator

It looks like you already create the custom iproperties when running the rule.

 

It automatically selects a sheet metal rule when creating a flat pattern (based off thickness). If you want more control over which face the flat pattern is made off of you can define an A-side before creating the flat pattern

0 Likes
Message 7 of 11

AnthonyB7
Enthusiast
Enthusiast
Yes I did have custom iproperties for the rule. I guess I dont need to define the side/face as long it is the correct thickness correct? .Thank you for helping me with this. Much appreciated.
0 Likes
Message 8 of 11

AnthonyB7
Enthusiast
Enthusiast
Hello, Dalton I have an issue now. So when I create a drawing view of the flat pattern and saves it, it works well but for some reason when I go back to my sheet metal part/model and do some changes, it deletes the flat pattern view in the drawing. Would you have any idea to why this is happening?
0 Likes
Message 9 of 11

dalton98
Collaborator
Collaborator

It looks like the flat pattern view on the drawing is linked to a specific flat pattern, so if you delete it it deletes the drawing view. I reread your original post and think i steered you in the wrong direction. 

I thought you wanted to delete old flat patterns, but you just want to map your iproperty values.

Simply delete the line "Return". That causes the code to end on that line, so it doesnt get to the lines that add the custom iproperties.

0 Likes
Message 10 of 11

AnthonyB7
Enthusiast
Enthusiast
Thank you for the quick reply Dalton, unfortunately I am having the same issue. I got rid of the "Return" but the same result. When I save the part it deletes the flat pattern view in the drawing.
0 Likes
Message 11 of 11

dalton98
Collaborator
Collaborator
Accepted solution

I ment the second return in your original code

If oCompDef.HasFlatPattern Then
	'Return
Else