iLogic picking up part volume (Solid 1 only)

iLogic picking up part volume (Solid 1 only)

Anonymous
Not applicable
3,272 Views
6 Replies
Message 1 of 7

iLogic picking up part volume (Solid 1 only)

Anonymous
Not applicable

Hi.

 

I have a part that I want to keep as an ipt rather than an assembly.  The part is a block with a thin plate attached either side.  I have created the block as "Solid 1" then offset a workplane 0.1mm from the side and extruded a 2mm plate as "Solid 2 (then mirrored as part of solid 2).

 

I have a bit of code sending the part volume to a custom iProperty and this is in turn picked up by the idw in a text box.

 

The volume being picked up is "The Part".  What I need to pick up is the volume for "Solid 1" only.

 

Is there a way I can set this or is there a bit of code that would do it?

 

Many thanks,

 

Terry

0 Likes
Accepted solutions (1)
3,273 Views
6 Replies
Replies (6)
Message 2 of 7

Fabian_perree
Advisor
Advisor

Hi @Anonymous ,

 

I can't find a way to do that without Ilogic.

 

I've done that some time before, (see part attached, Rule1) thanks to @MjDeck from his post here : https://forums.autodesk.com/t5/inventor-forum/body-volume-to-be-assigned-to-a-parameter/td-p/3634716.

once you've had the "SolidFunctions" in your code the rule is quite simple :

 

Dim bodies As New SolidBodies(ThisDoc.Document)
Volume1 = bodies.Body("Solide1").Volume
Volume2 = bodies.Body("Solide2").Volume

Best Regards

 

 

Fabian Perrée
Giùp.fr | LinkedIn

Ce post vous a été utile ? N'hésitez pas à aimer ce post.
Ce post a-t-il répondu à votre question ? Cliquez sur le bouton Accepter la solution.

EESignature

Cliquez ici pour accéder à toutes mes formations en ligne
Inventor 2022 : Modélisation et documentation de systèmes mécaniques
0 Likes
Message 3 of 7

Sergio.D.Suárez
Mentor
Mentor

Hi, here is an ilogic rule that you can place in your multibody file. You can add an event trigger to activate the rule every time you save the document. This rule will take the solid volume highlighted in red and place it in a custom property called "VolSolid1". Keep in mind that the units are in cm ^ 3. In the end you can specify the decimals you need.

Dim doc As PartDocument= ThisDoc.Document
Dim oCD As ComponentDefinition = doc.ComponentDefinition
Dim oSolid As SurfaceBody = oCD.SurfaceBodies(1)
Dim oVol As Double = oSolid.Volume(0.01)
'PrecisionPercent Double Input Double that specifies 
'the requested relative accuracy Of the result As a 
'percentage.For example, a value Of 0.01 requests a 
'maximum Error Of one percent.

iProperties.Value("Custom", "VolSolid1")= Round(oVol,3) & " cm^3"

 I hope this helps with your work. Grettings!!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 4 of 7

Anonymous
Not applicable

Thanks very much for both replies.

 

This is my existing code which picks up the part volume, converts it to dm3 and then ensures that it displays the first zero if the volume is < 1.

 

Dim oValue As String = (Format(Round(iProperties.Volume / 1000000, 3), ".000"))
		If oValue < 1 Then 
			iProperties.Value("Custom", "Vol (dm3)") = "0" & oValue
		Else
			iProperties.Value("Custom", "Vol (dm3)") = oValue
		End If

 

I guess the above suggested will need to be augmented with the existing bit of code (which is beyond my knowledge!).

 

Any help would be greatly appreciated.

 

Thanks,

 

Terry

 

 

 

0 Likes
Message 5 of 7

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Try the following. regards

Dim doc As PartDocument= ThisDoc.Document
Dim oCD As ComponentDefinition = doc.ComponentDefinition
Dim oSolid As SurfaceBody = oCD.SurfaceBodies(1)
Dim oVol As Double = oSolid.Volume(0.01) * 0.001 ' *0.001 is for dm^3

Dim oValue As String = (Format(Round(oVol, 3), ".000"))

If oValue < 1 Then 
	iProperties.Value("Custom", "Vol (dm3)") = "0" & oValue
Else
	iProperties.Value("Custom", "Vol (dm3)") = oValue
End If

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 6 of 7

Anonymous
Not applicable

Thanks a million Sergio.

 

I was just playing around with it and was almost there.......... but then it got further away, so your solution is very gratefully accepted!

 

Thanks again,

 

Terry

0 Likes
Message 7 of 7

mglockel
Observer
Observer

Thank you for posting this. Was struggling to find a way to measure to measure the volume of a body in a specific part. 

 

I have 2 bodies inside of a part, the first body I vary with parameters, and the second body is associated with the first. I can  now run a loop for the parameters of the first body until the desired volume is achieved on the second body. 

 

Appreciate it again!

0 Likes