TAGGED: acp, ironpython, python, python-scripting, workbench
-
-
December 6, 2020 at 3:32 pm
julius.langenhorst
SubscriberHello,nI wrote a script in ACP to extract shear angles at specific locations. This works fine as long as I run it directly in ACP.nI wrote another script in Workbench to update the next Design Point, Mechanical and ACP, then open ACP and run the ACP-script (= automate my parameter study). Now I'm getting an error basically saying that Ironpython does not support numpy. nI already know that it is not possible to get Ironpython working with numpy but the thing is that the command model.mesh_query creates a numpy.ndarray.nnTo avoid this problem, I tried different approaches:nRunScript(FilePath=E:/~/Script.py) This ends in the numpy no supported-errornnimport subprocessnrun_python = 'python -batch Script'nsubprocess.Popen(run_python) This does nothing but also not spitting out an error.nnfrom System.Diagnostics import Processnp = Process()np.StartInfo.UseShellExecute = Falsenp.StartInfo.RedirectStandardOutput = Falsenp.StartInfo.RedirectStandardError = Falsenp.StartInfo.CreateNoWindow = Truenp.StartInfo.FileName = 'E:/~/Script.py'np.Start()np.WaitForExit() Doesn't work since Script.py is not a executable file.nnWhat I would like to know now is how to get the script running. Is there a way to start the python engine where I can execute the script in (just like matlab.engine)? Or is it possible to go the other way around: starting in ACP and controlling workbench?nThank you very much.n -
December 8, 2020 at 11:41 am
cagdasakalin
Subscriber@waldmeistersweinnI have a related issue with script reading in ACP. As far as I understood, you are more ahead of me in terms of reading scripts in ACP.nDear all,According to the "Basic Scripting" procedure it is obvious that in ACP Pre module we can read copy commands appearing in "History View" and paste them in a notepad and save it as *.py. https://us.v-cdn.net/6032193/uploads/V2B84U8JSY8W/1.jpgI am trying to apply step by step what is written in the precedure as follows.https://us.v-cdn.net/6032193/uploads/KM3ATKZ3DPL9/3.jpghttps://us.v-cdn.net/6032193/uploads/QWAIFDF1ZBW9/4.jpghttps://us.v-cdn.net/6032193/uploads/WND8HLCMO9AJ/5.jpgI would appreciate it if you point out the part/step that I miss when I try to read from *.py file and explain why I am getting this "1 Error" window.https://forum.ansys.com/discussion/22594/acp-pre-script-file-reading
Can I kindly ask you to read my discussion for which I posted the link above, and give your suggestion regarding how to do it?, your answer and help is highly appreciated.n -
December 10, 2020 at 4:15 pm
Gary Stofan
Ansys EmployeenKnowledge Resources: Solutionsn#2052288nHow can I use Numpy or SciPy with ACT ?.Product Family: ScriptingnProduct: ANSYS Customization SuitenVersion: 18.2nArea: ACTnSubArea: N/AnLast Updated: Nov 29 2017nnAnswer:nnNumpy and SciPy are numerical libraries used with Python. ACT is based on IronPython and those libraries are not supported.nYou can use Math.net instead of Numpy or SciPy. Math.net is supported for IronPython and available for ACT. Libraries are in ANSYS Installation directory : C:\Program Files\ANSYS Inc\v182\Addins\ACT\bin\Win64\MathNet.Numerics.dllnnHere are some examplesnn----------------------------------------------nimport clrnimport Systemnimport osnclr.AddReferenceToFileAndPath(C:\\Program Files\\ANSYS Inc\\v182\\Addins\\ACT\\bin\\Win64\\MathNet.Numerics.dll)nn# Example 1nimport MathNetnfrom MathNet.Numerics.LinearAlgebra import *nV=Vector[System.Double].BuildnM=Matrix[System.Double].Buildnnm = M.Random(3,4)nv = V.Random(3)nnr=v*mnprint rnn# Example 2nimport MathNet.Numerics.LinearAlgebra as lannfrom System importas sys_arrayndef array(*x): return sys_array[float](x) #float is equivalent to .Net doublennA = la.Double.Matrix.Build.DenseOfRows(narray(3, 2,-1),narray(2,-2,4),narray(-1,.5,-1)n)nnb = la.Double.Vector.Build.DenseOf(array(1, -2, 0))nx = A.Solve(b)nnprint xnn# Example 3nA1 = la.Double.Matrix.Build.DenseOfRows(narray(3.0, 4.0, -1.0, 0.0),narray(4.0, 5.0, 0.0, -1.0),narray(5.0, 6.0, 0.0, 0.0),narray(6.0, 7.0, 0.0, 0.0)n)nb1 = la.Double.Vector.Build.DenseOf(array(0, 0, 20, 0))nx1 = A1.Solve(b1)nnprint x1nn
-
- The topic ‘Executing a python script in ACP out of Workbench’ is closed to new replies.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- How to do the frequency response of the nonlinear vibration of a flexible PCB?
- Importing Line and Solid Bodies from SpaceClaim to Mechanical
- how to open SendCommand in Ansys
- problems facing during solution
- Still facing the same issue
- Failed to move file from solver directory to scratch directory: file.rst
- Adaptive Sizing
- Stiffness factor
- Import DAT file
- Import pressure data (coordinates and value) to ansys workbench through excel
-
8808
-
4658
-
3151
-
1680
-
1470
© 2023 Copyright ANSYS, Inc. All rights reserved.