December 6, 2020 at 3:32 pmjulius.langenhorstSubscriberHello,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 amcagdasakalinSubscriber@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.n
Dear 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-readingCan 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 pmGary StofanAnsys 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
Earth Rescue – An Ansys Online Series
- 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
© 2023 Copyright ANSYS, Inc. All rights reserved.