Tracing the center of gravity of assembly in a dynamic simulation environment

Tracing the center of gravity of assembly in a dynamic simulation environment

Alexander_Chernikov
Mentor Mentor
1,582 Views
7 Replies
Message 1 of 8

Tracing the center of gravity of assembly in a dynamic simulation environment

Alexander_Chernikov
Mentor
Mentor

Good afternoon,


It is necessary to derive information about the change in the position of the center of gravity (COG) of the mechanism when modeling its movement in a dynamic simulation environment.


Although, it is written that there is a working point connected to the COG point, it is not possible to attach the tracing to it.

While it is necessary to manually stop the simulation process, display the COG indicator and rewrite the coordinates of its position.


If this is impossible inside the Inventor (v. 2018), I would like to get a clue, how to organize it using iLogic or VBA.


As an option, the output to the text (or Excel) file would be information about the current simulation time and X, Y, Z - coordinates of the current COG position.

Do you find the posts helpful? "LIKE" these posts! | Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням!
Have your question been answered successfully? Click "ACCEPT SOLUTION" button. | На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ"

Олександр Черніков / Alexander Chernikov

EESignature

Facebook | LinkedIn

.


0 Likes
1,583 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

I am new to this and I don't have any experience with the simulation part of the API nor do I have your code. I am wondering if you need to attach a proxy to the COG and then attach the trace to the proxy. Similar to the concept of creating a proxy for workpoints and planes for constraints in assemblies.

the concept would be 

 

define workpoint in component/assembly (CenterofMass property in the API has a good sample for this)

create proxy for workpoint in sim environment again handle well in the API. 

have event in simulation call routine to get proxy location (this should be in the "simulation coordinate system"\\

 

 

would love to try a crack at the code if you wouldn't mind/ can share. I always like a real world challenge

 

kl

 

 

0 Likes
Message 3 of 8

MechMachineMan
Advisor
Advisor

Is the time portion really important?

 

How are you making the simulation move?

 

I have code lying around that I could easily modify to drive an input parameters, update the model, and gather output data and then output to the excel file.

 

The only things you have control of though are start, stop, and step size for the input parameter.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 4 of 8

Alexander_Chernikov
Mentor
Mentor

Thanks for the answer,

 

Yes, the time portion is important?

 

Moving organized by graph of imposed motion of Wheels, Cabin and Jib.

 

 

I do the modeling and then, replay it, stopping the simulator at specified intervals, determine the COG coordinates.

Video of process can be seen on https://youtu.be/CcpHkqJLi2Y

 

It is desirable the code, which can do this in automatic mode.

 

Car1.PNGCar2.PNG

Do you find the posts helpful? "LIKE" these posts! | Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням!
Have your question been answered successfully? Click "ACCEPT SOLUTION" button. | На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ"

Олександр Черніков / Alexander Chernikov

EESignature

Facebook | LinkedIn

.


0 Likes
Message 5 of 8

Anonymous
Not applicable

You have probably already solved this, in case you haven't, here is what I have figured out with  my morning coffee. 95% is copy and paste from the API.

I have not had the time to double check that the proxy and workpoint remain tied to the COG. I believe in theory they should. Hope this helps and thanks for the interesting challenge. I used the catapult tutorial to develop this. 

 

kl

 

SyntaxEditor Code Snippet

Sub Main
    ' Set a reference to the active document.
    Dim oAsmDoc As AssemblyDocument
    oAsmDoc = ThisApplication.ActiveDocument
    
    ' The Dynamic Simulation environment must be active.
    Dim UIManager As UserInterfaceManager
    Try
    UIManager = ThisApplication.UserInterfaceManager
 
    If UIManager.ActiveEnvironment.InternalName <> "DynamicSimulationEnvironmentInternalName" Then
        ' Get the environment manager.
        Dim environmentMgr As EnvironmentManager
         environmentMgr = oAsmDoc.EnvironmentManager
 
        Dim dsEnv As Environment
        dsEnv = UIManager.Environments.Item("DynamicSimulationEnvironmentInternalName")
        Call environmentMgr.SetCurrentEnvironment(dsEnv)
    End If
     Catch ex As exception
    MessageBox.Show(ex.ToString, "Title")
    End Try

    ' Get the simulation manager from the assembly.
    Dim simManager As SimulationManager
    MessageBox.Show(oAsmDoc.ComponentDefinition.SimulationManager.ToString, "simManager")
    simManager = oAsmDoc.ComponentDefinition.SimulationManager
    
    ' Get the first simulation.  Currently there is only ever one.
    Dim sim As DynamicSimulation
    sim = simManager.DynamicSimulations.Item(1)
    
    ' Check to see if the simulation has already been computed.
    If sim.LastComputedTimeStep < sim.NumberOfTimeSteps Then
        ' Compute the simulation, which will also play it.
        sim.ComputeSimulation
    End If

    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry
    
    Dim oPartOcc As ComponentOccurrence
    oPartOcc = oAsmDoc.ComponentDefinition.Occurrences.ItemByName("Projectile:1")
    
    Dim oCOG As WorkPoint
    oCOG =  oPartOcc.Definition.WorkPoints.Item("Center of Mass") 
                        
    Dim pProxyCOG As WorkPointProxy
    oPartOcc.CreateGeometryProxy(oCOG, pProxyCOG)
    
    Dim interval as Long = 25
    Dim count As Long = 1
    
    oTxtFile = System.IO.File.CreateText(ThisDoc.PathAndFileName(False) & ".COG")    'create the file using the same name as the .iam and saves in the same location

    'first line
    oTxtFile.WriteLine("TIME    X Coord        Y Coord        Z Coord" )

    Try 
    While count < sim.NumberOfTimeSteps
        sim.PlaySimulation(count, (count + interval))
        count = count + interval
        oTxtFile.WriteLine(sim.CurrentTimeStep    &  pProxyCOG.Point.X & " " & pProxyCOG.Point.Y & " " & pProxyCOG.Point.Z)

    End While        
     Catch ex As exception
    MessageBox.Show(ex.ToString, "Title")
    End Try
    oTxtFile.Close
    
End Sub

 

 

 

Message 6 of 8

Alexander_Chernikov
Mentor
Mentor

Thanks for your example.

I'm just a beginner in iLogic.
When using your code, an error was received (see the figure).
Tip from the network to clean the temporary .Net files is executed, but the error has remained.
Can you advise any solution?

 

error in code.png

I have Windows7 x64 Prof. and Inventor 2018 with last updates.

 

Do you find the posts helpful? "LIKE" these posts! | Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням!
Have your question been answered successfully? Click "ACCEPT SOLUTION" button. | На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ"

Олександр Черніков / Alexander Chernikov

EESignature

Facebook | LinkedIn

.


0 Likes
Message 7 of 8

Anonymous
Not applicable

Alexander,

   I apologize for not getting back sooner I had finals this week. I am playing with code now and getting very strange results. When I work in a clean assembly , this is just using the dynamic sim tutorial.  I copy and paste the code into the assembly and run the code everything is fine. I can rerun the code multiple times. Go in and out of the sim environment change the interval, rerun the code everything is great. Once I save the file, after running the sim, everything goes off track and I get similar results as you. I am trying to get a better handle on the issue.

 

Respectfully

kl

 

Message 8 of 8

Anonymous
Not applicable

Alexander,

 

    I just wanted to let you know what is going on. I have tracked down the error we are getting. It appears that after running the dynamic simulation and saving the file, you can no longer compute the sim using the VB/ilogic call. It is really strange.  As long as I don't save the master assembly file after running the simulation everything works great. After saving the file, subsequent calls to ComputeSimulation does not change the LastComputedTimeStep. This causes the error we get when we try to PlaySimulation. I did all of the work using the catapult tutorial. I was curious if you were using the tutorial or your design when you encountered the problem?   

 

In the process of narrowing down the failure I crashed Inventor a few times. I let a few of the crash reports go through to Autodesk. The one I have been corresponding with them about is report #167162777. I don't know if there is any way for to follow the crash/bug but I'll let you know if I hear anything definitive.

 

On a slightly different note. I wrote the the original script with the intent of tracking the COG in the environment space. Looking through previous posts on the subject, I realized you might be wanting to the COG relative to your assembly. If you could clarify this I would appreciate it. 

 

Respectfully

kl

 

 

0 Likes