Send analysis update emails from Ansys | pyMechanical |
---|---|
1 Requirements SQL | 2 Data Modelling | 3 Ansys + SQL Server |
---|---|---|
4 MySQL Server | 5 PostgreSQL | |
---|---|---|
1 Excel & Ansys | 2 SQL Query on Excel |
---|---|
1 Introduction | 2 Command Window & ACT Console | 3 Python Basics |
---|---|---|
4 DataModel, Project & Model | 5 Selection Manager | 6 Geometry |
---|---|---|
7 Geodata | 8 Named Selection | 9 Quantity |
---|---|---|
10 Units | 11 Materials | 12 Engineering Data Materials |
---|---|---|
13 Coordinate Systems | 14 Connections | 15 Contact Region |
---|---|---|
16 Joints | 17 Bushing Worksheet | 18 Named Selection Worksheet |
---|---|---|
19 Mesh | 20 MeshData | 21 Analyses & Analysis |
---|---|---|
22 Analysis Settings | 23 Multi Step Load | 24 Inertial Loads |
---|---|---|
25 Structural Supports | 26 Structural Loads | 27 Bolt Pretension |
---|---|---|
28 Solutions & Results | 29 Export Graphics Pane | 30 Export Tabular Pane |
---|---|---|
31 Export Worksheet Pane | 32 Export Graph Pane | 33 Graphics |
---|---|---|
[![Graphics] |
In IronPython, clr
is a module allows which you to work with .NET assemblies and interact with .NET objects. clr.AddReference
, clr.AddReferenceToFile
, and clr.AddReferenceToFileAndPath
are methods provided by clr
to add references to .NET assemblies. The choice of which method to use depends on your specific requirements and the location of the assembly you want to reference.
clr.AddReference(assembly_name)
: This method is used to add a reference to a .NET assembly by its name. It's often used when the assembly is already in the Global Assembly Cache (GAC) or is available in the current application domain. Here's an example:
import clr
clr.AddReference("System.Windows.Forms")
# Now you can use classes from the System.Windows.Forms assembly
import System.Windows.Forms
form = System.Windows.Forms.Form()
clr.AddReferenceToFile(assembly_file)
: This method is used when you have the assembly file (DLL) available locally, and you want to reference it by specifying the file path. Here's an example:
import clr
clr.AddReferenceToFile("C:/Path/To/Assemblies/MyAssembly.dll")
# Now you can use classes from the MyAssembly assembly
import MyNamespace
my_instance = MyNamespace.MyClass()
clr.AddReferenceToFileAndPath(assembly_file, search_paths)
: This method is similar toclr.AddReferenceToFile
, but it allows you to specify a list of directories to search for the assembly. This can be useful when the assembly is not in the current working directory, and you want to specify additional search paths. Here's an example:
import clr
search_paths = ["C:/Path/To/Assemblies", "D:/Another/Path"]
clr.AddReferenceToFileAndPath("MyAssembly.dll", search_paths)
# Now you can use classes from the MyAssembly assembly
import MyNamespace
my_instance = MyNamespace.MyClass()
In summary, use clr.AddReference
when the assembly is in the GAC or the current application domain, clr.AddReferenceToFile
when you have the assembly file locally, and clr.AddReferenceToFileAndPath
when you have the assembly file but need to specify additional search paths. The choice depends on the availability and location of the assembly you want to reference in your Python code.