Getting m^3 to show up as Volume units in form.

Getting m^3 to show up as Volume units in form.

Anonymous
Not applicable
4,372 Views
7 Replies
Message 1 of 8

Getting m^3 to show up as Volume units in form.

Anonymous
Not applicable

First time posting a question here, so please bear with me and I'm sorry if I didn't post in the right place.

 

I have a Tank assembly...in which, I have two parts that represent the water levels (one at max fullness, one up to the overflow).

 

This is my code that drives the Volume portions of my Form. 

 

I want the Volume to show up in m^3 and I have no idea how to do it, as m^3 isn't a choice in my parameter units. In iProperties, the volume of both water parts shows correctly, with the m^3 as the units.

 

My question is...how do I get the Volume and the Gross Volume to show up in my form the way it is showing in my iProperties tab (with m^3 as the units)?

 

 

SyntaxEditor Code Snippet

Parameter("Skeleton - MASTER:1", "InletWaterLevel")=TopsidePipeDisFromTop-Flange_Gap

    'Suppress Water, If Not Needed
If Water="Add Water" Then
    Component.IsActive("Volume of Water:1")=True
    
ElseIf Water="Remove Water" Then
    Component.IsActive("Volume of Water:1")=False 
    
End If


Select Case Water
    Case "Add Water"
    formAddRemoveWater= True
    
    Case "Remove Water"
    formAddRemoveWater = False
End Select

VolumeOfWater=iProperties.VolumeOfComponent("Volume of Water:1")


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



    'Suppress Gross Water, If Not Needed
If GrossWater="Add Water" Then
    Component.IsActive("Gross Volume of Water:1")=True
    
ElseIf GrossWater="Remove Water" Then
    Component.IsActive("Gross Volume of Water:1")=False 
    
End If


Select Case GrossWater
    Case "Add Water"
    formGrossVolumeOfWater= True
    
    Case "Remove Water"
    formGrossVolumeOfWater = False
End Select

GrossVolumeOfWater=iProperties.VolumeOfComponent("Gross Volume of Water:1")

 

 

 Capture.PNG

 

I am using Inventor 2017...and I am very new to Inventor and iLogic.

 

I also would like to have "Update" buttons next to the volumes that would update the volumes and that would unsuppress the correct water part too (instead of the add/remove water buttons)....but I am afraid that might be over my head at the moment.

 

Thanks so much!

Maggie

0 Likes
Accepted solutions (1)
4,373 Views
7 Replies
Replies (7)
Message 2 of 8

Curtis_Waguespack
Consultant
Consultant

Hi mnorton4BH7P,

 

"m^3 isn't a choice in my parameter units"

 

You can just type in m^3 for the units (not sure why it's not listed).

 

As for the rest of this, I'm not sure I followed how you have it set up, but I've done it more like the attached in the past. And have just driven this model from the assembly with a form. In the attached the form is in the part just for simplicity.

 

Post back if it's not clear.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 3 of 8

Anonymous
Not applicable

Typing in m^3 in the parameters worked.

 

I didn't realize that I didn't have to "choose" the units and they could be typed in but I don't understand why m^3 isn't IN the table.

 

I looked at your model's rules and I really don't know what exactly I'm looking at. Like I said, I am just learning iLogic...so I really only know what I have had to make it do for my application.

 

Is there a way for me to attach my assembly here?

 

I would also like to round my Volumes to two decimal places and have a way to update the numbers when my water level changes via overflow height change, without having to suppress and unsupress the Water "parts".

0 Likes
Message 4 of 8

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi Mrs.Norton,

 

To attach an assembly, use pack and go to round up all of the parts, and then place them in a zip file and attach that file here.

 

My file was set up with 2 named solid bodies, created by splitting a revolved part with a work plane. The parameter called Fill, is the parameter that sets the work plane offset. The form drives this parameter, and therefore adjusts the split location of the two solid bodies. The iLogic rule gets the volume of these named solid bodies, and multiplies them by the relative error percentage, then converts them from cubic cm to cubic m, and rounds them to 2 places. And finally it sums the 3 volumes to give the total volume as a user parameter.

 

I commented the code a bit better and included it below.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Volume iLogic.JPG

 

'triggers make rule run automatically
'when parameter is changed
oTrigger = Dia
oTrigger = Dia2
oTrigger = Fill

Dim partDoc As PartDocument = ThisDoc.Document
Dim oSurfBodies As ObjectCollection

'Relative Error percentage
Dim RelErr As Double
RelErr = 0.641322 

'look at each solid body
For Each sb As SurfaceBody In partDoc.ComponentDefinition.SurfaceBodies
	'find body by name
	If sb.Name = "Liquid" Then 
		'get volume times relative error percent
		V1 = sb.Volume(RelErr) 
		'round and multiple by conversion factor 
		'0.000001 for cm^3 To m^3
		Volume = Round(V1 * 0.000001,2) 
		'find body by name
	ElseIf sb.Name = "Air" Then 
		'get volume times relative error percent
		V2 = sb.Volume(RelErr) 
		'round and multiple by conversion factor 
		'0.000001 for cm^3 To m^3
		Volume2 = Round(V2 * 0.000001,2) 
	End If
Next

'sum volumes of both bodies
'write to user parameter TotalVolume
TotalVolume = Volume + Volume2

EESignature

Message 5 of 8

Anonymous
Not applicable

Here is my file...not sure if you will be able to open it or not.

 

Please don't mind the way I have the flanges linked in the rule, as I didn't know how to get them to change sizes 😕

0 Likes
Message 6 of 8

Curtis_Waguespack
Consultant
Consultant

Hi Mrs.Norton,

 

The zip file did not contain the part and assembly files, but I think I have a fair idea of what you're after.

 

Attached is a really simple assembly that has a vessel, an overflow, and a contents file. It's likely not exactly how you want it to work, but should give you some ideas how to proceed.

 

  • The Contents file is the master or skeleton file that drives the other files, they were derived from it. This file contains the previous illogic code I posted.

 

  • The Assembly has parameters that either push or pull values to/from the contents file. It does this via an iLogic rule in it, that triggers the rule in the contents part file.

 

  • The overflow level is controlled in the contents file by a work plane, and derived into the overflow part model.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 7 of 8

Anonymous
Not applicable

Thanks so much! That really helped.

 

The only issue I am having now is how to round the volume to two decimal places.

 

I edited it in the Parameter using "Custom Property Format" but it isn't showing rounded in either my parameter list or in my form.

 

Thanks for your help!

 

0 Likes
Message 8 of 8

Curtis_Waguespack
Consultant
Consultant

Hi Mrs.Norton,

 

I was rounding in the "contents" file , so that the value comes into the assembly (and therefore the form) already rounded. Will that work, or do you need to do the rounding at the assembly level?

 

This rounds to 2 places:

Volume = Round( V1 * 0.000001, 2)

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

EESignature

0 Likes