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

(Not an Autodesk Employee)