Inventor Dynamic Simulation API Capabilities

Inventor Dynamic Simulation API Capabilities

mechamania
Advocate Advocate
1,759 Views
19 Replies
Message 1 of 20

Inventor Dynamic Simulation API Capabilities

mechamania
Advocate
Advocate

Reference Post: Dynamic Simulation API

 

On the last API chart I see some Dynamic Simulation objects. So is it possible now?

0 Likes
1,760 Views
19 Replies
Replies (19)
Message 2 of 20

chandra.shekar.g
Autodesk Support
Autodesk Support

@mechamania,

 

Yes, Dynamic simulation objects are exposed in Inventor API 2018.

 

May I know the requirement on dynamic simulation API? so that I can do feasibility study.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 20

mechamania
Advocate
Advocate

We would like to simulate none linear braking systems like shock absorbers.

 

Regards.

 

0 Likes
Message 4 of 20

mechamania
Advocate
Advocate

The force of these absorbers depend on compression speed.

0 Likes
Message 5 of 20

chandra.shekar.g
Autodesk Support
Autodesk Support

@mechamania,

 

Can you please provide sample shock absorber file (Non confidential) to check feasibility?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 6 of 20

mechamania
Advocate
Advocate

This is best I can find. See attachment. The faster you press it, the more force you will feel.

0 Likes
Message 7 of 20

chandra.shekar.g
Autodesk Support
Autodesk Support

@mechamania,

 

With image, not possible to do feasibility study. Could you please provide sample shock absorber (Non confidential) file to study?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 8 of 20

mechamania
Advocate
Advocate

(Sorry for late reply. Had to spent time on other parts of the project.)

 

This is the absorber:

 

http://www.acecontrols.com/us/products/safety-products/safety-shock-absorbers/scs33-to-scs64/scs45/s...

 

Problem is that I can not find more specific data.

 

I want to approach its behaviour with a force that depends on velocity (of pressing the pinion). That will be good enough for me. But I do not know how to do that.

 

 

 

0 Likes
Message 9 of 20

chandra.shekar.g
Autodesk Support
Autodesk Support

@mechamania,

 

 

Can you please provide assembly files of shock absorber to study the feasibility of Simulation? Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 10 of 20

mechamania
Advocate
Advocate

This problem became important again and I still do not know it this can be done with the dynamic simulation API.

 

This is what we would like to do:

We would like to read each simulation timestep some positions and velocities of body parts. Then calculate some forces and apply these forces on specific joints.

 

Can that be doen using the API?

0 Likes
Message 11 of 20

YuhanZhang
Autodesk
Autodesk

The current Dynamic Simulation API provides the ability to query the timestep and the playback speed etc., you can compute the position and velocity of the parts by yourself and so you can compute the forces too.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 12 of 20

mechamania
Advocate
Advocate

Hi Rocky Zhang,

That sounds interesting!

So each simulation time step, I can read positions and speeds of the different parts, and set (change) forces of some joints?

If so, are there examples of that?

If not, how do you advise me to start with this? API is new for me. But I'm an experienced programmer.

 

0 Likes
Message 13 of 20

mechamania
Advocate
Advocate

I played with the API for a while. I can access the document model and write code to do manipulate the model. But I do not see how to access the DynamicSimulation. Do I have to access the SimulationManager somehow? I do not see how?

 

0 Likes
Message 14 of 20

mechamania
Advocate
Advocate

Ok, I found an VBA example that does start a Dynamic Simulation Playback. So now I know how to access the Dynamic Simulation.

But I can not find out how to step through the simulation step by step. There is a function to compute to a certain simulation step. But I see no way to start at the begin. I do not see a reset or so.

0 Likes
Message 15 of 20

YuhanZhang
Autodesk
Autodesk

The CurrentTimeStep is read-write property which allows you to reset the simulation, below is a VBA sample for it, you should firstly in UI enter the simulation environment:

 

Sub simSample()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSimManager As SimulationManager
    Set oSimManager = oDoc.ComponentDefinition.SimulationManager
    
    Dim oDynSim As DynamicSimulation
    Set oDynSim = oSimManager.DynamicSimulations(1)
    
    '  play the simulation
    oDynSim.PlaySimulation
    
    '  reset the simulation
    oDynSim.CurrentTimeStep = 1
    
End Sub


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 16 of 20

mechamania
Advocate
Advocate

But that is for playback.

I would like to do the computations step by step to be able to change forces during the simulation.

0 Likes
Message 17 of 20

mechamania
Advocate
Advocate

I tried the code below.

sim.NumberOfTimeSteps is 50, so the loop runs 50 times. But oCalculatedStep does not change (is always the value 51). And after running and checking the graph, the Force does not change (not set to 0 after 19 simulation steps).

What am I doing wrong?

The documentations says that ComputeSimulation will run the simulation steps from currentTimeStep to the given parameter. So this should work, right?

 

 

    ' Get the simulation manager from the assembly.
    Dim simManager As SimulationManager
    Set simManager = asmDoc.ComponentDefinition.SimulationManager
    ' Get the first simulation.  Currently there is only ever one.
    Dim sim As DynamicSimulation
    Set sim = simManager.DynamicSimulations.Item(1)
    ' Get the force variable
    Dim joint As DSJoint
    Set joint = sim.DSJoints.Item(1)
    Dim value As DSValue
    Set value = joint.Definition.DegreesOfFreedom.Item(1).LoadForce
    
    ' Calculate the simulation
    Dim step As Integer
    Dim oCalculatedStep As Integer

    oCalculatedStep = sim.LastComputedTimeStep
    
    For step = 2 To sim.NumberOfTimeSteps
         sim.CurrentTimeStep = step-1
         sim.ComputeSimulation (step)
         oCalculatedStep = sim.LastComputedTimeStep
         If step >= 20 Then
            value.ConstantValue = 0
         End If

    Next
    
    sim.PlaySimulation

 

0 Likes
Message 18 of 20

YuhanZhang
Autodesk
Autodesk

There seems a problem wit the API, can you send me a testing data(don't send confidential data), I can log a bug for dev to investigate it.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 19 of 20

mechamania
Advocate
Advocate

I attached a pack-and-go zip file. It contains a very simple assembly with dynamic simulation. A cylinder is moved over a rod by a constant force. So it accelerates during the simulation. As a test I try to stop the acceleration somewhere in the middle of the simulation by setting the force to zero using the API. But it doesn't work.

I  do not know if the VBA code is automatically part of the pack-and-go file. So here is the code:

Sub PlaySimulation()
    ' Get the active document.  This assumes it is an assembly.
    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument
    
    ' The Dynamic Simulation environment must be active.
    Dim UIManager As UserInterfaceManager
    Set UIManager = ThisApplication.UserInterfaceManager
    If UIManager.ActiveEnvironment.InternalName <> "DynamicSimulationEnvironmentInternalName" Then
        ' Get the environment manager.
        Dim environmentMgr As EnvironmentManager
        Set environmentMgr = asmDoc.EnvironmentManager
    
        Dim dsEnv As Environment
        Set dsEnv = UIManager.Environments.Item("DynamicSimulationEnvironmentInternalName")
        Call environmentMgr.SetCurrentEnvironment(dsEnv)
    End If
         
    ' Get the simulation manager from the assembly.
    Dim simManager As SimulationManager
    Set simManager = asmDoc.ComponentDefinition.SimulationManager
    
    ' Get the first simulation.  Currently there is only ever one.
    Dim sim As DynamicSimulation
    Set sim = simManager.DynamicSimulations.Item(1)
    
    ' Get the force variable
    Dim joint As DSJoint
    Set joint = sim.DSJoints.Item(1)
    Dim value As DSValue
    Set value = joint.Definition.DegreesOfFreedom.Item(1).LoadForce
    
    
    ' Calculate the simulation
    Dim step As Integer
    Dim oCalculatedStep As Integer

    sim.CurrentTimeStep = 1
    
    
    oCalculatedStep = sim.LastComputedTimeStep
    
    For step = 2 To sim.NumberOfTimeSteps
        sim.CurrentTimeStep = step - 1
        sim.ComputeSimulation (step)
        oCalculatedStep = sim.LastComputedTimeStep
        If step >= 20 Then
            value.ConstantValue = 0
        End If

    Next
    
    sim.PlaySimulation
    
End Sub

 

Note that the simulation should be active otherwise the code gives an error.

0 Likes
Message 20 of 20

YuhanZhang
Autodesk
Autodesk

I logged a bug for this, you can provide the INVGEN-26747 to query its status.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes