Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Center of Mass in iLogic

9 REPLIES 9
Reply
Message 1 of 10
C-nalA
2758 Views, 9 Replies

Center of Mass in iLogic

How do I get the center of mass of a part using iLogic and input either its x, y, or z components into a parameter?
I've been grinding my head against this problem for a few hours, and I just can't make it work. Not sure if this will help, but the part I'm trying to make is a self-balancing camshaft. Basically, given the center of mass of each lobe on the shaft, I want to use iLogic to compute two parameters which will define a counter-weight that will make the camshaft's center of gravity coincident with its rotation axis. I specifically need the y-component of the center of gravity of each lobe...

If anyone can help me out here I'd greatly appreciate it,
Alan Campbell
9 REPLIES 9
Message 2 of 10
swordmaster
in reply to: C-nalA

Hi,
I have not tried to read the COG using ilogic, but it is covered in the help file

pt = iProperties.CenterOfGravity

Read the center of gravity of the model in the document the rule is in.

pt is of the type Inventor.Point

You can read the X, Y and Z values of the point (which are in the units of the rule document):

cx = pt.X

cy = pt.Y

cz = pt.Z

please let me know if this helps
Inventor 2010 Certified Professional
Message 3 of 10
C-nalA
in reply to: C-nalA

Yep, that works. Thanks a lot for your time.

Alan Campbell
Message 4 of 10
swordmaster
in reply to: C-nalA

Good!
Any chance you could share your ilogic rule?
Might be useful in the future...thanks
Inventor 2010 Certified Professional
Message 5 of 10
C-nalA
in reply to: C-nalA

I can share the rules for it, however I don't think I can share the part which uses them, because I created it in a beta build of Inventor 2011 (whose files cannot be read by Inventor 2010). The part has three rules in it, two of which compute data about the center of gravity, mass, and volume of two of its three 3D features. I think I mentioned this before, but the part I'm trying to make is a camshaft, the reason I'm using iLogic to help make it is because I need to create a counter-weight with perfectly cancels out the offset in the camshaft's center of gravity induced by its cam-lobe. What iLogic tries, and at this point is successfully able to compute, is the length of the extrusion which defines the counter-weight's thickness. The third rule collects parameter data generated by the first two rules and computes what this extrusion length should be. Explaining what everything does with a screen-shot would be pretty easy to do, but my confidentiality agreements don't permit to post screen-shots until the 25th of March. But alas, here is a copy of my code with comment lines in it.

'First rule in the optimization process, it determines the current center of gravity of the counter-balance weight. CBWeight is the extrusion that defines the counter-balance weight, Shaft is the extrusion which defines the core shaft that both the cam-lobe and counter-weight are attached to. Inventor cannot (as far as I can tell) find the center of gravity/volume/mass of a specific feature in a part, so what this rule first does is suppress the extrusions which define the cam-lobe ('CamLobe') and the shaft.'
Parameter.UpdateAfterChange = True
If Feature.IsActive("CBWeight") = True Then
Feature.IsActive("Shaft") = False
Feature.IsActive("CamLobe") = False
End If
'Once the relevant features are disabled, the rule then evaluates the y-axis position of CBWeight's center of gravity and its mass (although the mass value of this feature is not used to determine its shape).'
centerPt = iProperties.CenterOfGravity
CBWeightCG = centerPt.y
CBWeightM = iProperties.Mass
'The next two lines unsuppress the CamLobe extrusion and load the second rule.'
Feature.IsActive("CamLobe") = True
iLogicVb.RunRule("CamLobe Center of Gravity Calculator")

'2nd Rule... This pretty much does the same thing as the last rule, it suppresses every feature except the CamLobe extrusion and finds both the y-axis position of the CamLobe's center of mass and the CamLobe's total mass (which also is not used, I just like having it in my parameters table for reference). It also finds the CamLobe's volume (parameter CamLobeV), this is used in the calculation to determine the magnitude of parameter CBWT (the magnitude of the extrusion CBWeight).'
If Feature.IsActive("CamLobe") = True Then
Feature.IsActive("Shaft") = False
Feature.IsActive("CBWeight") = False
End If
centerPt2 = iProperties.CenterOfGravity
CamLobeCG = centerPt2.y
CamLobeM = iProperties.Mass
CamLobeV = iProperties.Volume
'Re-enables all of the suppressed features so the model looks as it should normally,I probably should mention that running both rules 1 and 2 takes only a tiny fraction of a second, so you never actually get to see the suppression/unsuppression process happen.'
Feature.IsActive("Shaft") = True
Feature.IsActive("CBWeight") = True
'Loads rule 3, which calculates, given the data produced by rules 1 and 2, what CBWT should be.'
iLogicVb.RunRule("CBWeight Thickness and Mass Calculator")

'Rule 3, d0 is the diameter of the circle which defines the sketch used in the 'Shaft' extrusion, PI is just the number 3.14159265358979.... Adjusts the length of Extrusion CBWeight so that the mass of the feature said extrusion produces can offset the center of gravity of the Cam-Lobe'
CBWT = Abs(2*CamLobeV*CamLobeCG/(PI*CBWeightCG*((CBWW+d0/2)^2-(d0/2)^2)))


I'll post screen-shots of the part two days from now when my agreements expire, sorry if this doesn't make a whole lot of sense. Well, anyways enjoy.

Alan Campbell
Message 6 of 10
C-nalA
in reply to: C-nalA

This rule set does actually work, it can balance the center of gravity of the camshaft to within .002 millimeters of where it's supposed to be. Not really sure why there's an error in the first place, I'm guessing it has to do with various weird ways of double precision floating point numbers.

Alan Campbell
Message 7 of 10
swordmaster
in reply to: C-nalA

Hi,
Actually your code makes a lot of sense.
Its always good to see how other users are making use of ilogic

thanks
Inventor 2010 Certified Professional
Message 8 of 10
C-nalA
in reply to: C-nalA

Ok, so here is a copy of my self-optimizing camshaft. I've added comments to all of the relevant parameters, so getting it to work should be pretty straight forward. After updating the parts' critical dimensions and parameters, manually run rule 'CBWeight Center of Gravity Calculator' then run 'CamLobe Center of Gravity Calculator'. The third rule in the list will run on its own after running rule two. If you don't have a copy of Inventor 2011, respond, and I'll post some screen-shots of the part optimizing its own center of gravity.

Enjoy! 🙂
Alan Campbell
Message 9 of 10
swordmaster
in reply to: C-nalA

Thanks Alan,
Unfortunately I don't have 2011 yet....so if you find the time screenshots would be nice
Inventor 2010 Certified Professional
Message 10 of 10
C-nalA
in reply to: C-nalA

Sorry for taking so long to respond to this, my quantum physics class decided it wanted to hurl a test at me and I've been studying quite a bit for it. I also decided to set up a LinkedIn account in the pathetic hope it'll help me find a job over the summer as a CAD technician, which chewed up a decent chunk of time as well. Additionally, I've somehow never needed to make a rotation-translation type pattern in Inventor before and had to learn how to make curve-driven patterns. Finally, I ended up semi-substantially recoding some of the rules in my part to account for the presence of some extra 3D features. The sum of all these things is what's caused me to take so long to respond. I'm going to paste a copy of the iLogic code, this time without comments in the space below.

I've also included some screen shots and the most recent version of the part itself in a zip file.


Parameter.UpdateAfterChange = True
Feature.IsActive("CBWeight") = True

If Feature.IsActive("CBWeight") = True Then
Feature.IsActive("Shaft") = False
Feature.IsActive("CamLobe") = False
Feature.IsActive("Shaft Extension") = False
Feature.IsActive("Rectangular Pattern1") = False
End If
centerPt = iProperties.CenterOfGravity
CBWeightCG = centerPt.y
CBWeightM = iProperties.Mass
Feature.IsActive("CamLobe") = True
iLogicVb.RunRule("CamLobe Center of Gravity Calculator")

------------------------------------------------------------------------------------------------------------------

If Feature.IsActive("CamLobe") = True Then
Feature.IsActive("Shaft") = False
Feature.IsActive("CBWeight") = False
Feature.IsActive("Shaft Extension") = False
Feature.IsActive("Rectangular Pattern1") = False
End If
centerPt2 = iProperties.CenterOfGravity
CamLobeCG = centerPt2.y
CamLobeM = iProperties.Mass
CamLobeV = iProperties.Volume

Feature.IsActive("Shaft") = True
Feature.IsActive("CBWeight") = True
Feature.IsActive("Shaft Extension") = True
Feature.IsActive("Rectangular Pattern1") = True

iLogicVb.RunRule("CBWeight Thickness and Mass Calculator")

----------------------------------------------------------------------------------------------------------

'Adjusts the length of Extrusion CBWeight so that the mass of the feature said extrusion produces can offset the center of gravity of the Cam-Lobe'
CBWT = Abs(2*CamLobeV*CamLobeCG/(PI*CBWeightCG*((CBWW+d0/2)^2-(d0/2)^2)))

'Warning! Don't make Sketch5 Un-Adaptive! Doing so makes the model sort of explode.'
If d29 <= 0 Then
Feature.IsActive("CBWeight") = False
MessageBox.Show("A problem has occured, the CBWeight is oversized and would intersect other features in the part. Try decreasing the size of the cam-lobe.", "Over-Size Cam-Lobe.")
End If

Enjoy!
Alan Campbell

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report