Find sheet metal parts which flat pattern can not be done.

Find sheet metal parts which flat pattern can not be done.

alp
Explorer Explorer
620 Views
5 Replies
Message 1 of 6

Find sheet metal parts which flat pattern can not be done.

alp
Explorer
Explorer

I try to add line to ilogic code below to find problematic sheet metal parts. (Sometimes designers forget to select thickness sheet metal default or some problems on sketch etc.)  

 If flat pattern view can not be generated then write "error" on custom iproperties. After the running code I can easily check problematic part from BOM parts only. 

 

However I can not able to find correct code to point to problematic sheet metal part. 

 

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDrawDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If

Is there any way to find problematic sheet metal part with ilogic? 

 

0 Likes
Accepted solutions (1)
621 Views
5 Replies
Replies (5)
Message 2 of 6

raith-mb
Advocate
Advocate

You can check the RangeBox of the Flat Pattern.

Compare the Z-Value to the Sheet Metal Thickness.
If Z is higher, it is not flat.

 

Roland.

0 Likes
Message 3 of 6

alp
Explorer
Explorer

Hi,

Thanks for the answer. 

Has problematic sheet metal part Rangebox Z value?. I try to use ShowBox.Show(oCompDef.FlatPattern.RangeBox.MaxPoint.Z()) for each part. When it comes to problematic sheet metal part showbox does not appear. Maybe This kind of parts do not have Z value? 

 

I also try to use but it did not work. 

	If oCompDef.FlatPattern.RangeBox.MaxPoint.Z() <> oCompDef.FlatPattern.Parameter(oCompDef, "Thickness")
	MessageBox.Show("Error")
End If

 

0 Likes
Message 4 of 6

marcin_otręba
Advisor
Advisor

Try this:

 

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDrawDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
oCompDef.FlatPattern.ExitEdit
End If If oCompDef.HasFlatPattern = False Then
MessageBox.Show("Error")
Else
If (oCompDef.FlatPattern.RangeBox.MaxPoint.Z()-oCompDef.FlatPattern.RangeBox.MinPoint.Z()) <> oCompDef.Thickness.Value then
MessageBox.Show("Error")
End
If
End If

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 5 of 6

WCrihfield
Mentor
Mentor
Accepted solution

This should do what you're wanting:

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works on Sheet Metal Part Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oSMDoc As PartDocument = ThisApplication.ActiveDocument

If oSMDoc.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value <> "Sheet Metal" Then
	MsgBox("This isn't a Sheet Metal Part. Exiting rule.",vbOKOnly, " ")
	Return
End If
Dim oSMDef As SheetMetalComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition


Dim oCustProps As PropertySet = oSMDoc.PropertySets.Item("Inventor User Defined Properties")
Dim oCProp As [Property]
Dim oFlatPatternCheck As [Property]
Dim oExists As Boolean = False
If oCustProps.Count > 0 Then
	For Each oCProp In oCustProps
		If oCProp.Name = "Flat Pattern Check" Then
			oFlatPatternCheck = oCProp
			oExists = True
		End If
	Next
End If
If oExists = False Then
	oFlatPatternCheck = oCustProps.Add("Unknown", "Flat Pattern Check")
End If

If oSMDef.HasFlatPattern = False Then
	Try
		oSMDef.Unfold
		oFlatPatternCheck.Value = "OK"
	Catch ex As Exception
		MsgBox("Had no flat pattern found. Attempt to unfold failed.", vbOKOnly, " ")
		oFlatPatternCheck.Value = "Error"
	End Try
Else
	oFlatPatternCheck.Value = "OK"
End If

 

 

 

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

 

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here
  • Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 6

alp
Explorer
Explorer

@marcin_otręba Thank you for the reply. I also tried before to run oCompDef.Hasflatpattern = False loop but It didn't work out. I am using Inventor 2019.

 

@marcin_otręba I did with try and catch command. Thank you. 

 

Last version is below.  I prefer to add "error" letter to iproperties custom section. Maybe I did it with in a hard way. But it did. 

 

If oCompDef.HasFlatPattern = False Then
Try 
oCompDef.Unfold Catch Dim HataFullDocumentName As String = oCompDef.Document.FullDocumentName Dim HataFileNameOnly As String Dim index As Integer = HataFullDocumentName.LastIndexOf("\") HataFileNameOnly = HataFullDocumentName.Substring(index + 1) iProperties.Value(HataFileNameOnly, "Custom", "Error") = "Error" oDrawDoc.close End Try  
Else 
oCompDef.FlatPattern.Edit
End If 

 

0 Likes