Discussion Groups

Simulation Moldflow Insight

Reply
Contributor
MFI-MaF
Posts: 19
Registered: ‎02-17-2013

Using Variables in macros

304 Views, 9 Replies
11-13-2013 01:15 AM

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
Please use plain text.
Contributor
MFI-MaF
Posts: 19
Registered: ‎02-17-2013

Re: Using Variables in macros

11-14-2013 12:53 AM 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

Please use plain text.
Product Support
nordhb
Posts: 453
Registered: ‎03-23-2009

Re: Using Variables in macros

11-14-2013 01:15 AM in reply to: MFI-MaF

Hi,

change the row to:

 

Plot.SaveXYPlotCurveData (Pfad)

 That should do it.

 

Regards,

Berndt



Berndt Nordh