- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I have been working on a rule to add the weight/mass of the first drawing view on each sheet of a .idw to the title block, via prompted entry. This may not be the best way, (open to ideas)
I have found a view rules (attached, not my own), first rule creates a custom iProperty of the mass of each LOD in the assembly. The second rule allows me to copy those custom iProperties from source to drawing.
So the values exist in the drawing file, but I can't get the rule to check if the drawing view matches the custom iProperty, if it does then return the weight/mass value. If it doesn't then return 0.
The rule is setup to:
-first check for the first view in each sheet(if applicable)
-add Custom iProps to an Array
-ensure correct titleblock is active for prompted entry (typically only use one for now)
-**check first view on drawing sheet has matching Custom iProperty, if yes then return value
-input weight/mass value to 2nd prompted entry
I am not sure if I created the array correctly, and/or am matching the first view with custom iprop correctly. The rule operates without error, but it doesn't return any value to the 2nd prompted entry. I have another rule setup to also populate a prompted entry, it grabs the sheet name in the browser and populates the title block field. So maybe that prompted entry is interfering somehow?
'CHECK EACH SHEET FOR FIRST VIEW
Dim oEachSheet
Dim oFirstview
Dim oEachDocumentOffirstview
For Each oEachSheet In ThisApplication.ActiveDocument.Sheets
oFirstview = oEachSheet.DrawingViews(1)
oEachDocumentOffirstview = oFirstview.ReferencedDocumentDescriptor.ReferencedDocument
customPropertySet = oEachDocumentOffirstview.PropertySets.Item("Inventor User Defined Properties")
MessageBox.Show("RULE CHECK 1", "Title")
'ADD CUSTOM iPROPS TO ARRAY
On Error Resume Next
Dim invDoc As Document : invDoc = ThisApplication.ActiveDocument
oCommandMgr = ThisApplication.CommandManager
Dim invDesignInfo As PropertySet
invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
Dim oList As New ArrayList
oList.Add("Design Tracking Properties:")
oList.Add("")
invDoc = ThisApplication.ActiveDocument
invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
Dim invPartNumberProperty As [Property]
For Each invPartNumberProperty In invDesignInfo ' iterate through the commands and write to file
oList.Add(invPartNumberProperty.Name & " --> " & invPartNumberProperty.Value)
Next
oList.Add("")
oList.Add("Inventor User Defined Properties:")
oList.Add("")
invDesignInfo = invDoc.PropertySets.Item("Inventor User Defined Properties")
For Each UnoInvProp2 In invDesignInfo
oList.Add(UnoInvProp2.Name & " --> " & UnoInvProp2.Value)
Next
'ENSURE CORRECT TITLEBLOCK IS ACTIVE WITH PROMPTED ENTRY
Dim oDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("Teksign_Large")
oSheet = oDrawDoc.ActiveSheet
MessageBox.Show("RULE CHECK 2", "Title")
'IF DRAWING VIEW HAS MATCHING CUSTOM iPROP THEN ADD VALUE TO PROMPTED ENTRY "WEIGHT"
If customPropertySet = invDesignInfo Then
Weight = invPartNumberProperty.Value
'THIS IS SECOND PROPTED ENTRY IN TITLEBLOCK, FIRST PROMPTED ENTRY PUTS SHEET NAME IN TITLEBLOCK
Dim sPromptStrings(1) As Double
sPromptStrings(1) = Weight
Dim stringYouNeed2 As String = Weight
sPromptStrings(1) = stringYouNeed2 'if there is only one promped entry
oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef, , sPromptStrings)
End If
Next
MessageBox.Show("RULE CHECK 3", "Title")
Product Designer at Teksign Inc.
Inventor 2016 SP1
Dell Precision 3660
i7-12700 @ 2.40GHz-4.90GHz
32GB DDR5 4400MHz RAM
NIVDIA RTX A2000 6GB
Solved! Go to Solution.