Hello All!
Plant 3D 2013 (ver G.55.00), Win7 64-bit.
We permanently meet an error after Plant command
(TESTACPSCRIPT "TESTSCRIPT")
Traceback (most recent call last):
File ".\variants\varmain\__init__.py", line 94, in create
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
nil
Here's a steps to reproduce:
1) create simple script TESTSCRIPT (see attachement). Save it as "C:\AutoCAD Plant 3D 2013 Content\CPak Common\CustomScripts\TestScript.py". You can save it in ANSI or UTF-8 encoding, it does not matter
2) Open plant 3d. In command line write such strings
PLANTREGISTERCUSTOMSCRIPTS
(arxload "PnP3dACPAdapter.arx")
(TESTACPSCRIPT "TESTSCRIPT")
What's wrong,please help me! Also there's a strange behavior with (TESTACPSCRIPT1 "TESTSCRIPT") which does not produce an errors, but also it is not produce errors when using any other script name, like (TESTACPSCRIPT1 "anY_text_Here")
How to test scripts????
Solved! Go to Solution.
Solved by kudryavcevrm. Go to Solution.
solved. Don't forget to quit autocad after PLANTREGISTERCUSTOMSCRIPTS.
But :
script errors are very uninformative(spurious),i.e. many of error messages are similar :(, like
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)
How to debug scripts?????????????? Can I use native Phyton IDLE debugger??????
you need a parameter name in your script...
instead of:
def TESTSCRIPT(s, D=80.0, L=150.0, OF=-1, K=1, **kw):
CYLINDER(s, R=D/2, H=L, O=0.0).rotateY(90)
you need it to read:
def TESTSCRIPT(s, D=80.0, L=150.0, OF=-1, K=1, **kw):
o1 = CYLINDER(s, R=D/2, H=L, O=0.0).rotateY(90)
That's the first thing I noticed. The o1 can be anything. I just tend to use o for OBJECT and 1 for the sequence, or first solid object. The next object would be o2, o3, o4, etc. I know you are just testing this out but you have translate options as well to move the solid around in X, Y or Z directions.
Give that a try.
I tried this. I cannot get any metafiles to procude in the customscripts directory. Does anyone know what the problem is?