Hi, simple question:
how to get in iLogic a mass od one solid? I have a ipt file with two solids, I need mass just one of them. The drawing will explain everything.
Now I'm using this code, which was OK before I add a "CUT" feature.
'==================== Masa=Measure.Area("FIELD") mass=Val(Masa)/1000000 'cm3->m3 density=0.83 mass = mass * density * width Masa=CStr(mass) ' mass of one pocket '=====================
I'm also attaching tha part. Please move End of part to the end of history, it was to big to post here.
The parameters names are in Polish, don't be afraid 😉 Masa = mass
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Vladimir.Ananyev. Go to Solution.
SurfaceBody.Volume Property returns volume in base units that allows you estimate desired mass of this solid body.
Thanks for advice,
how I get to this SurfaceBody?
I've tried
Masa=oDoc.ComponentDefinition.Document.ComponentDefinitions.Item(1).SufraceBodies.Item(2).ComponentDefinition.MassProperties.Area
But with no result..
The following sample prints the volume of the first two surface bodies in the active part. You should play a little to find appropriate RelErr value (see Inventor API help).
Private Sub Test() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition Set oDef = oDoc.ComponentDefinition Dim RelErr As Double RelErr = 0.01 Dim oBody As SurfaceBody Dim V1 As Double, V2 As Double Set oBody = oDef.SurfaceBodies.Item(1) V1 = oBody.Volume(RelErr) Debug.Print V1 Set oBody = oDef.SurfaceBodies.Item(2) V2 = oBody.Volume(RelErr) Debug.Print V2 End Sub
The simplest way to get density (g/mm^3) :
Dim Density1 As Double
Density1 = oDef.material.Density
Cheers,
Just posting this code to this old thread for reference:
'define the document as a component definition Dim oCompDef as ComponentDefinition oCompDef = ThisDoc.Document.ComponentDefinition 'define the solidbody Dim oBody As SurfaceBody 'define the solid body name to look for Dim body As String sBody = "Solid1" Dim oVolume As Double Dim oDensity As Double oDensity = oCompDef.Material.Density oConversion = 0.00220462 'gram to lbs 'get mass of named solid body i = 1 For Each SurfaceBody In oCompDef.SurfaceBodies oBody = oCompDef.SurfaceBodies.Item(i) If sBody = oBody.Name Then oVolume = oBody.Volume(0.001) ' (g/mm^3) oMass = Round(oVolume * oDensity * oConversion,2) MessageBox.Show("Mass of " & oBody.Name & " = " & oMass & " lbmass", "iLogic") End If i = i +1 Next