- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
I have been using this code to extract various iProperty values and write them to user parameters:
'Checks for existing COG, mass, volume and surface area parameters, and creates each if necessary 'Publishes database values to parameters 'Checks for 3d volume, and if nothing exists, ends rule Volume1 = iProperties.Volume 'MessageBox.Show(Volume1, "Volume1") If Volume1 = 0 Then Exit Sub End If Dim oApp As Inventor.Application = ThisApplication Dim oParams As Parameters Dim oPartDoc As PartDocument = ThisDoc.Document Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition oParams = oPartCompDef.Parameters Dim oUserParams As UserParameters = oParams.UserParameters 'Volume Try p = oParams.Item("Volume") Catch oPara = oParams.AddByValue("Volume", 0, "in^3") End Try Parameter("Volume") = Round(iProperties.Volume,2) 'Mass Try p = oParams.Item("Mass") Catch oPara = oParams.AddByValue("Mass", 0, "lbmass") End Try Parameter("Mass") = Round(iProperties.Mass,2) 'Surface_Area Try p = oParams.Item("Surface_Area") Catch oPara = oParams.AddByValue("Surface_Area", 0, "in^2") End Try Parameter("Surface_Area") = Round(iProperties.Area,2) 'COG_x Try p = oParams.Item("COG_x") Catch oPara = oParams.AddByValue("COG_x", 0, UnitsTypeEnum.kInchLengthUnits) End Try Parameter("COG_x") = Round(iProperties.CenterOfGravity.X, 3) 'COG_y Try p = oParams.Item("COG_y") Catch oPara = oParams.AddByValue("COG_y", 0, UnitsTypeEnum.kInchLengthUnits) End Try Parameter("COG_y") = Round(iProperties.CenterOfGravity.Y, 3) 'COG_z Try p = oParams.Item("COG_z") Catch oPara = oParams.AddByValue("COG_z", 0, UnitsTypeEnum.kInchLengthUnits) End Try Parameter("COG_z") = Round(iProperties.CenterOfGravity.Z, 3)
The code runs fine on parts, but I would to tweak it to run for assemblies as well.
Any help is greatly appreciated.
TIA
Solved! Go to Solution.