Message 1 of 3

Not applicable
08-02-2018
01:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a rule which inserts the 'z' value of the bounding box for each part in an assembly into the iproperty value 'vendor'
this works fine when I run it in the assembly level, but if I happen to have a drawing file open, it will reprt an error.
I cant understand why......any help?
Version:1.0 StartHTML:00000145 EndHTML:00004951 StartFragment:00000294 EndFragment:00004919 StartSelection:00000294 EndSelection:00000294SyntaxEditor Code Snippet
'Find all parts in this assembly that contain parameter name G_L 'Convert the boundary box z dimension into an iProperty fmgr = ThisApplication.FileManager For Each file In fmgr.files doc = ThisApplication.Documents.ItemByName (file.fullfileName) compdef = doc.ComponentDefinition If (doc.documenttype = 12291) Then 'Only do this for assembly or subassembly For Each occ In compdef.Occurrences If (occ.definition.type = 83886592) Then 'Only do this for part Try 'Look for existance of G_L parameter TempG_L = Parameter(occ.Name, "G_L") Catch 'Part does not contain G_L GoTo skipThisPart End Try 'Found a file containing G_L templen = Round(10*(occ.definition.RangeBox.MaxPoint.Z - occ.definition.RangeBox.MinPoint.Z),1) templen = Ceil(templen) 'Rounds the result to next whole number 'Push this number value into an unused iProperty iProperties.Value(occ.Name, "Project", "Vendor") = templen skipThisPart: End If Next occ End If Next File InventorVb.DocumentUpdate() 'Update the model
Solved! Go to Solution.