I am using Python scripts to create custom pipe supports but, there is a problem when I try to import a custom script into another custom script. The host script runs successfully in test but, does not run in production. I have successfully imported standard Plant 3D Python scripts into custom scripts and therefore believe the problem may have something to do with the syntax of the import declaration. Below are the import declarations used in the host script. "B1A" is the custom script I am importing.
from aqa.math import *
from varmain.primitiv import *
from varmain.var_basic import *
from varmain.custom import *
from B1A import *
Any help would be appreciated.
Solved! Go to Solution.
Solved by twdtech. Go to Solution.
I have an update to this problem. If I run the import script "B1A" into a drawing, I can then successfully run the host script which is importing script "B1A". However, if I do not place "B1A" into a drawing then the host script will not run. Anyone know how I can fix this problem?
I have found the solution. It was a pathing issue. Once I added a reference in the script to the path of the CustomScripts folder the issue was resolved.
I think I'm having the same problem. Can you post your script and tell me what you changed to make it work?
Please solution
Can you post your script and tell me what you changed to make it work?
I currently also had the same problem - and i have found the solution.
With the following script-code the path to the custom-scripts will be added to the search-paths:
import os import sys sys.path.append(os.path.normpath(sys.PnP3dNativeContentCustomScriptsPath))
After that you can use
from B1A import *
for loading the custom script "B1A".
Python scripting is easier than other languages. In this, we will use the extension .py, just to help us know that the script contians python code and not standard UNIX shell commands.
The first script that we will use will be a simple script that will output the text "Hello Python". You can use any file editor, personally, I use vi. Create a file named "hello.py" and use the following for its contents:
#!/usr/bin/env python
# This is my first script.
print "Hello Python"
Hello,
I am trying to learn to write script with phyton.
When I type below line, it gives me errror "
from varmain.flangesub.cpfwo import "ImportError: No module named varmain.flangesub.cpfwo"
is there anybody to help me?
Anyone at all? I'm having the same issue, go to register the script and Plant 3D is telling me there is no module named ******......... Please help. Post up your Python knowledge please!!