You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Dynamo version of Topologic relies on an older DLLs. topologicpy relies on newer DLLs and has desirable added features for use with pyRevit CPython. I am trying to use methods from Topologic in Dynamo graphs and topologicpy in pyRevit in the same Revit session. If Topologic Dynamo graphs are used first subsequent topologicpy CPython scripts can't import necessary modules. If topologicpy CPython scripts are used first subsequent Topologic Dynamo graphs have broken nodes because Dynamo claims it cannot find the required Topologic package.
Dynamo graph has broken nodes because Dynamo claims it cannot find the required package.
Expected behavior
I was hoping the CPython environment would be isolated in something like a virtual environment. But it seems like DLLs are applied universally in a Revit session. As a result, the Dynamo Topologic package based on Python infrastructure that varies across distribution channels includes functions whose use is mutually excluded. This was not expected.
Desktop (please complete the following information):
Additional context
The observed behavior is probably more of a mechanization observation than a bug. However, as an end user the behavior presents itself like a bug.
I looked around for a way that pyRevit might trigger a python script to run in an environment external to Revit. For my use case that should work well enough. However, I was not able to find guidance on how pyRevit might trigger a python script to run in an environment external to Revit.
Thank you for your consideration.
The text was updated successfully, but these errors were encountered:
Running a subprocess fit the bill perfectly in that a Python script can be run outside the pyRevit environment. This keeps dependencies separated from one another which facilitates interoperability despite package versioning over time. Basic bundle setup:
program.py
programSubprocess_script.py
An example programSubprocess_script.py:
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 21 14:20:00 2023
@author: Ripcord Engineering (JPS)
"""
import os
# use subprocess to run external programs in Python 3
# https://www.digitalocean.com/community/tutorials/how-to-use-subprocess-to-run-external-programs-in-python-3
import subprocess
# path to virtual environment python.exe
BIN_PATH = [os.environ['USERPROFILE'], 'anaconda3', 'envs', 'pyRevit', 'python']
python_bin = os.path.join(*BIN_PATH)
# path to file to run in virtual environment
SCRIPT_PATH = [os.path.dirname(os.path.abspath(__file__)) ,'RemoveCellBRepCoplanarFaces.py']
# print(SCRIPT_PATH)
script_file = os.path.join(*SCRIPT_PATH)
# print(script_file)
# open subprocess in virtual environment and wait for completion
# https://stackoverflow.com/questions/28284715/python-subprocess-popen-wait-for-completion
# https://stackoverflow.com/questions/7575284/check-output-from-calledprocesserror
try:
subprocess.check_output([python_bin, script_file], shell=True, stderr=subprocess.STDOUT).decode()
msg = 'File processing is complete!'
except subprocess.CalledProcessError as e:
msg = e.output.decode()
except Exception as e:
msg = str(e)
print(msg)
Given the general interest in using Python packages, it would be beneficial to include detailed documentation on how pyRevit can make use of subprocesses.
jpstaub
changed the title
pyRevit - Dynamo Incompatibility: Two versions of Same Topologic DLL
pyRevit - Dynamo Incompatibility: Two versions of Same DLL
Feb 15, 2023
Describe the bug
The Dynamo version of Topologic relies on an older DLLs. topologicpy relies on newer DLLs and has desirable added features for use with pyRevit CPython. I am trying to use methods from Topologic in Dynamo graphs and topologicpy in pyRevit in the same Revit session. If Topologic Dynamo graphs are used first subsequent topologicpy CPython scripts can't import necessary modules. If topologicpy CPython scripts are used first subsequent Topologic Dynamo graphs have broken nodes because Dynamo claims it cannot find the required Topologic package.
The problem concept faced seems to be described fairly well by: How to use two versions of the same DLL in the same project.
To Reproduce
Run Topologic Dynamo graph,
Run topologicpy CPython script,
topologicpy CPython script cannot import necessary module.
Run topologicpy CPython script,
Run Topologic Dynamo graph,
Dynamo graph has broken nodes because Dynamo claims it cannot find the required package.
Expected behavior
I was hoping the CPython environment would be isolated in something like a virtual environment. But it seems like DLLs are applied universally in a Revit session. As a result, the Dynamo Topologic package based on Python infrastructure that varies across distribution channels includes functions whose use is mutually excluded. This was not expected.
Desktop (please complete the following information):
Additional context
The observed behavior is probably more of a mechanization observation than a bug. However, as an end user the behavior presents itself like a bug.
I looked around for a way that pyRevit might trigger a python script to run in an environment external to Revit. For my use case that should work well enough. However, I was not able to find guidance on how pyRevit might trigger a python script to run in an environment external to Revit.
Thank you for your consideration.
The text was updated successfully, but these errors were encountered: