Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Custom Property: SheetMetalLength
- Custom Property: SheetMetalWidth
Having build up the model, I assign almost all the iProperties at the time of details the document (part, sheet metal part, derived part, assembly, drawing itself, ..) at thetimeof creating the production drawings.
My current rule is comprehensive and doing well, but it is lacking of creating custom properties in case the model in the drawing is a sheet metal part.
I was not successful although I spent a lot of time.
'Get active document Dim oDoc_in_Dwg As Document oDoc_in_Dwg = ThisDoc.ModelDocument 'Get active document unit of measure Dim uom As UnitsOfMeasure = oDoc_in_Dwg.UnitsOfMeasure 'Converts length unit to a string Dim Units As String = uom.GetStringFromType(uom.LengthUnits) 'Checks To see If the active document Is a standard part If oDoc_in_Dwg.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Then 'If it Is a standard part we convert it to sheet metal Try oDoc_in_Dwg.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Catch 'catch error and exit rule when part can't be converted 'example: multiple solid body part Return End Try End If 'Check if the part is sheet metal now If oDoc_in_Dwg.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 'Go To the FlatPattern Dim oSMCD As SheetMetalComponentDefinition oSMCD = oDoc_in_Dwg.ComponentDefinition 'Look For Flatpattern If Not oSMCD.HasFlatPattern Then 'Create Flatpattern If the part doesn't have one oSMCD.Unfold() oDoc_in_Dwg.Update2(True) oSMCD.FlatPattern.ExitEdit() Else MessageBox.Show("SHEET METAL " & "Flat Pattern found", "Title") 'https://forums.autodesk.com/t5/inventor-forum/ilogc-rule-to-delete-2-user-parameters-and-create-2-custom/td-p/6486777 'suppress user parameters Dim Width As String = "SheetMetalWidth" Dim Length As String = "SheetMetalLength" Dim oDef As ComponentDefinition = oDoc_in_Dwg.ComponentDefinition Try Dim oParW As UserParameter = oDef.Parameters.UserParameters.item(Width) Dim oParL As UserParameter = oDef.Parameters.UserParameters.item(Length) oParW.Delete oParL.Delete oDoc_in_Dwg.Update Catch MessageBox.Show("User parameter don't exist", "iLogic rule") ' Return 'exit rule End Try iProperties.Value(oDoc_in_Dwg, "Custom", "SheetMetalLength")=Round(SheetMetal.FlatExtentsLength,2) iProperties.Value(oDoc_in_Dwg, "Custom", "SheetMetalWidth")=Round(SheetMetal.FlatExtentsWidth,2) End If End If
Rule and Samples attached.
Inv 2019 Professional/Vault Professional
Solved! Go to Solution.