Skip to content

How to Import clr and AddReference using pymechanical embedded #1035

Answered by koubaa
B-Naveen-Kumar asked this question in Q&A
Discussion options

You must be logged in to vote

Hello,

With CPython, you need to add the reference before importing the namespace.

So it would look more like:

clr.AddReference("Microsoft.Office.Interop.PowerPoint")
import Microsoft

I tried it, and python doesn't know where to find that reference. I found it in my system in the GAC at this location: C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.PowerPoint\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.PowerPoint.dll

I was able to get this to work:

>>> import ansys.mechanical.core as mech
>>> app=mech.App(version=252)
>>> import clr
>>> clr.AddReference(r"C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.PowerPoint\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Pow…

Replies: 9 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dipinknair
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants