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: 

Using Variables in macros

9 REPLIES 9
Reply
Message 1 of 10
MFI-MaF
856 Views, 9 Replies

Using Variables in macros

Hello everybody,

 

I'm working on a macro to automate the output of my wanted result files. I made an Input box where the user put in the Node ID and the path of the result file. I've tried to place the variables at the wanted positions in the script, but Moldflow ignores the input.

 

Here is the problematic part of my macro:

 

Does anybody know how i can solve the problem with those two variables?

 

Thanks

 

UserInput = Inputbox("Call node:")
Pfad = Inputbox ("Where do you want to place the resultfile? (z.B.: c:\...\):")


SetLocale("en-us")
Set Synergy = CreateObject("synergy.Synergy")
Synergy.SetUnits "Metric"
Set StudyDoc = Synergy.StudyDoc()
Set EntList = StudyDoc.CreateEntityList() '* create an empty entity list
Set PlotManager = Synergy.PlotManager()
Set Plot = PlotManager.CreatePlotByDsID(1180, True)
Plot.SetXYPlotShowLegend True
Set Viewer = Synergy.Viewer()
Set Plot = Viewer.ActivePlot()
Set PlotManager = Synergy.PlotManager()
Set Plot = PlotManager.FindPlotByName2("Pressure:XY Plot", "Pressure")
Set Viewer = Synergy.Viewer()
EntList.SelectFromString ("& UserInput &")  '* popoulate the entity list
Plot.AddXYPlotCurve(EntList)  '* plot the curve of entity
Viewer.ShowPlot Plot
Plot.SaveXYPlotCurveData ("& Pfad")


EntList.SelectFromString ("& UserInput")  'First problem line
Plot.SaveXYPlotCurveData ("& Pfad")         'second problem line

 

 

 

My next problem is that this code just works for pressure on this way. If I want to use the macro for fiber orientation I have to open the wanted result before runnung the macro:

 

setLocale("en-US")
Set Synergy = CreateObject("synergy.Synergy")
Synergy.SetUnits "Metric"
Set PlotManager = Synergy.PlotManager()
Set Viewer = Synergy.Viewer()
Set probePlot = Viewer.ActivePlot()
Set VectorA = Synergy.CreateVector()
Set VectorB = Synergy.CreateVector()
VectorA.SetXYZ -4.34, 0, -9.6	'ERSTE VEKTORKOORDINATE (Startpunkt)'
VectorB.SetXYZ -4.34, 3, -9.6	'ZWEITE VEKTORKOORDINATE (Endpunkt)'
probePlot.AddProbePlotProbeLine VectorA, VectorB'
probePlot.SaveXYPlotCurveData "& Pfad" '

probePlot.Regenerate

 

Thank you
9 REPLIES 9
Message 2 of 10
MFI-MaF
in reply to: MFI-MaF

Hi,

 

my first problem, I solved on myself. My fault was a wrong input

EntList.SelectFromString ("& UserInput &")

and this is the correct way:

EntList.SelectFromString (""& UserInput )

 But if someone has an idea for my second problem, it would be very nice if you post it 🙂

 

Thanks

Message 3 of 10
nordhb
in reply to: MFI-MaF

Hi,

change the row to:

 

Plot.SaveXYPlotCurveData (Pfad)

 That should do it.

 

Regards,

Berndt



Berndt Nordh
Message 4 of 10
MFI-MaF
in reply to: nordhb

Hi,

 

sorry I didn't said I've also solved this problem, but thanks 🙂

 

Now my problem is to start the script for fiber-orientation without opening the result before. I think that I have to write some configurations in the code like the components xx,yy,zz for example.

 

Thanks

Message 5 of 10
nordhb
in reply to: MFI-MaF

Hi,

good you sorted this out.

 

You could use this to find results and plot:

Set Plot = PlotManager.FindPlotByName( "Pressure")
Viewer.ShowPlot Plot 

 Note: The plot name must agree exactly with the result name you want to plot.

 

Hope this helps.

 

Regards,

Berndt



Berndt Nordh
Message 6 of 10
MFI-MaF
in reply to: nordhb

Hi,

 

my macro runs now. But one thing I would like to optimize. At the fiber orientation result, you can choose in the options which component you like to take, for exaple (axx,ayy,azz) is it possible to define this and also other components like a13 or a23 and so on?

 

 

Thank you for your help.


Message 7 of 10
nordhb
in reply to: MFI-MaF

Hi,

in the plot properties, tab Tensor, you can select the Tensor component such as component of:

Txx or Tyy or Tzz or
Txy or Txz or Tyz

 

Regards,

Berndt 



Berndt Nordh
Message 8 of 10
MFI-MaF
in reply to: nordhb

Hi,

 

yes and that I would like to automate in my macro, because I've got a lot of simulations and not enough time to make this manually.. I would like to use this option on the same way I used the other variables before.

I

 

Like this :

 

UserInput = Inputbox("Choose the tensor component: ")

 

And then put the variable at the right position in the code. But I don't know how to realize this, and macro recording don't show it.

 

 

Thanks

Message 9 of 10
MFI-MaF
in reply to: MFI-MaF

Has anybody an idea how I can define which tensor component should be used in the macro?

 

 

Thanks

Message 10 of 10
nordhb
in reply to: MFI-MaF

Hi,

there is a bit of programming to do this.

You have to extract the fiber tensor information for the node.

 

This is from API reference, which you can find from Autodesk Simulation Moldfow Synergy user interface,

in top-right of window, to the right of question-mark, click the small arrow down and select "API Reference"

 

This example gets tensor result data 4000 (Average fiber orientation)

 

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

By steping through timestep, find node, and get wished tensor you can then build your customized XY-graph.

 

Hope this helps.

 

Regards,

Berndt



Berndt Nordh

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

Post to forums  

Autodesk Design & Make Report