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

API macro command reference (Synergy object)

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
celifani
2480 Views, 9 Replies

API macro command reference (Synergy object)

Hello all,

I would like to write a macro to read position and corrensponding fiber orientation.

I found some good example in the help file concerning node coordinate but I have no idea how to read fiber orientation.

 

Is there somewhere a reference with a comprehensive list of command which can be used in vbscript when working with Synergy objects?

 

Thanks a lot,

Claudio

9 REPLIES 9
Message 2 of 10
nordhb
in reply to: celifani

Hi,
you can use information in Help as starting point:
In Synergy:

To find examples and more:
Help > Search Help...
tab Contents
Application Programming Interface (API)

 

and

 

Help > API References
To find
Class List
Class Index
Class Members
Also short examples available here.


Basically to read fiber orientation is to read a result data set.
This is an example how to get data of Average Fiber Orientation result:
 SetLocale("en-us")
 Set Synergy = CreateObject("synergy.Synergy")
 Synergy.SetUnits "Metric"
 PlotMgr= Synergy.PlotManager()
 Set IndpValues = Synergy.CreateDoubleArray()
 PlotMgr.GetIndpValues 4000, IndpValues
 Set Ind = Synergy.CreateDoubleArray()
 Ind.AddDouble IndpValues.Val( IndpValues.Size - 1 )
 Set node_1  = Synergy.CreateIntegerArray()
 Set P11 = Synergy.CreateDoubleArray()
 Set P22 = Synergy.CreateDoubleArray()
 Set P33 = Synergy.CreateDoubleArray()
 Set P12 = Synergy.CreateDoubleArray()
 Set P13 = Synergy.CreateDoubleArray()
 Set P23 = Synergy.CreateDoubleArray()
 PlotMgr.GetTensorData 4000, Ind, node_1, P11, P22, P33, P12, P13, P23


To learn about specific code, you can start the macro recording, do the commands within Synergy, stop recording,
save the macro and edit and review.


Regards,
Berndt



Berndt Nordh
Message 3 of 10
celifani
in reply to: nordhb

Dear Berndt,

thanks a lot for your reply and the code you posted, it was exaclty what I was looking for and I'm sure I'll be able to perform the task I was aiming to.

 

But I still have some small problem concerning the help documentation; I'm still unable to locate the API reference you described in your reply. Even if I type "API references" or "Class List" in the search field of the help I'm not able to find that documentation. What do you mean exacly when you said "In Synergy:"?

I'm working on a Japanese computer with the English language pack installed, might be some problem for the help files? My Moldflow version is the 2011.

 

Thanks again,

best regards,

Claudio

Message 4 of 10
celifani
in reply to: celifani

Hello again,

 

first of all there is a little mistake in your code:

Set PlotMgr= Synergy.PlotManager()

[Set was missing]

 

The code is running without errors but it returns arrays with zero dimension; none of the 7 arrays (P11,P22,P33,P12,P13,P23,node_1) contains data to be read. The problem seems starting from IndipValues since this array as well result being zero dimensional.

 

Do you have the same problem when running the code?

 

Thanks again,

regards,

Claudio

Message 5 of 10
nordhb
in reply to: celifani

Hi Claudio,
Synergy is the UI, User Interface, of Autodesk Moldflow Insight.
Autodesk Moldflow 2011 has a new Ribbon UI, but one can also run in Classic UI mode.

 

In the Synergy Ribbon UI, you have the question mark at upper right corner:
Click on the small arrow down just to the right of the question mark:
select "API reference"
select tab Classes


In the Synergy Classic UI:
Help > API reference



Right, it should of course be Set PlotMgr= Synergy.PlotManager()



The script works, and you get the values such as:
Ind.Val(i)
node_1.Val(i)
P11.Val(i)


Average fiber orientation example:
For each time step there will be result or not, depending if flow reached node/element.
If you want result at last time step, you have to count to last step.


Regards,
Berndt



Berndt Nordh
Message 6 of 10
celifani
in reply to: nordhb

Hello Berndt,

 

First of all, thanks for the help concerning the documentation, I found the API reference and know it's getting ways much better, thanks!

 

Concerning the code: I found the reason why I had zero dimensional arrays when I tried to run it.

To read fiber orientation the resultID has to be set at 4021. A loop can then be set to obtain average information.

4000 represents the Average Fiber Orientation but it seems to be of no use...

 

In any case thanks again I won't have been able to continue without your support!

 

Regards,

Claudio

Message 7 of 10
nordhb
in reply to: celifani

Hi Claudio,
thank you. Happy to help.

 

Just to clarify the result id's.
Result id is also mesh dependent:
- 4000 is Average Fiber Orientation results for Midplane and Dual Domain models.
- 4021 is Fiber orientation tensor result for 3D tetra models.


Regards,
Berndt



Berndt Nordh
Message 8 of 10
celifani
in reply to: nordhb

Hello!

 

I'm back again to my old post since I have a new small question concerning the same topic.

 

The question is: where do you get the result ID? I searched in the help but I might looked in the wrong section or not all IDs are given. I'm actually interested in knowing the code for the Fiber Orientation Tensor for tetra element (if possible). 4021 gives it for nodes and I would like to have the same for tetras.

 

Regards,

Claudio

Message 9 of 10
nordhb
in reply to: celifani

Hi,

result id:

- 4021 is Fiber orientation tensor nodal result for 3D tetra models.

- 4009 is Fiber orientation tensor elemental result for 3D tetra models.

 

To get result id, you can use GetDataID().

Copy and paste below to ResultID.vbs, and save in C:\My AMI 2011 Projects\commands.

You need to have a completed analysis and tick the result.

Then run command ResultID.

 

Regards,

Berndt

 

'@ Note: The script/macro is provided 'as-is' and cannot be liable for any problems caused.

'@

'@ DESCRIPTION

'@ command to get result name, result ID and data type

'@

'@ SYNTAX

'@ ResultID <enter>

'@

SetLocale("en-us")

Dim Synergy

Set Synergy = CreateObject("Synergy.Synergy")

Synergy.SetUnits "METRIC"

Set Viewer = Synergy.Viewer

If Viewer Is Nothing Then

MsgBox "Please, select a study.",,"Error"

WScript.Quit

End If

Set Plot = Viewer.ActivePlot()

If Plot Is Nothing Then

MsgBox "Please, select a result.",,"Error"

WScript.Quit

End If

ResultID = Plot.GetDataID

ResultName = Plot.GetName

ResultData = Plot.GetDataType

MsgBox "ResultName= " & ResultName & " , has ResultID= " & ResultID & " (Type: " & ResultData & ")"



Berndt Nordh
Message 10 of 10
celifani
in reply to: celifani

Perfect! It was exacly what I was looking for!

 

Thank you very much, I think now the topic is definetely closed Smiley Wink

 

Regards,

Claudio

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

Post to forums  

Autodesk Design & Make Report