Autodesk / civilconnection

CivilConnection enables the exchange of information between Civil 3D, Dynamo and Revit.
94 stars 43 forks source link

CivilPython unable to load standard libraries #26

Closed htlcnn closed 4 years ago

htlcnn commented 4 years ago

Hi, I'm using CivilPython with Civil 3D 2020. I'm not able to import standard libraries such as os. Here's the code:

import os

And the Exception thrown:

Traceback (most recent call last):
File "....\script.py", line 1, in <module>
ImportError: No module named os

Please give some instructions on how to attach IronPython Standard Library to CivilPython.

Thanks!

paoloemilioserra commented 4 years ago

import sys sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')

htlcnn commented 4 years ago

Thanks. I wonder if there is other way to embed IronPython stdlib into CivilPython.dll so that it doesn't rely on client's installation path?

Edit: Nevermind, I've found solution at: https://github.com/eirannejad/pyRevit/blob/master/dev/pyRevitLoader/Source/ScriptExecutor.cs#L136-L146

Thanks a lot for your help. And please remember to escape your strings.