Python files(PYC) do not work in shared folders

Python files(PYC) do not work in shared folders

Anonymous
Not applicable
1,666 Views
8 Replies
Message 1 of 9

Python files(PYC) do not work in shared folders

Anonymous
Not applicable

After I generated the Python scaffold file locally, I changed the path of the shared folder to the network shared folder. The scaffold component generated by Python is not available, and there is no problem with the built-in graphics.

Using the error in P3D is shown below,anybody can help me ,thanks.

The folder path is \\199.244.20.12\Plant 3D\库文件\AutoCAD Plant 3D 2021 Content,It contains the files in the entire CONTENT.

error in P3D:

Traceback (most recent call last):
File "varmain\__init__.pyc", line 84, in dynloadVariant
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
找不到表示指定的零件的符号。

0 Likes
Accepted solutions (1)
1,667 Views
8 Replies
Replies (8)
Message 2 of 9

Thimo.Bergen
Enthusiast
Enthusiast

Hi,

There is an error in your code. Aparently there seems to be a problem converting a string into Unicode.
You should contact your python developer.

 

Or upload the code so we can locate the fault.

0 Likes
Message 3 of 9

Anonymous
Not applicable

Here is the code , It works fine when it works locally

import aqa.math
import math
from varmain.primitiv import *
from varmain.custom import *

@Anonymous(Group="Support", Ports="1", TooltipShort="Pipe Clamp", TooltipLong="Pipe Clamp with threaded rod", LengthUnit="mm")
@group("MainDimensions")
@param(D=LENGTH, TooltipShort="Inside diameter of pipe support. (Matches the Pipe diameter)", TooltipLong="Inside diameter of pipe support. (Matches the Pipe diameter)")
@param(L=LENGTH, TooltipShort="Length of the clamp", TooltipLong="Length of the clamp")
@param(W=LENGTH, TooltipShort="Thickness of the clamp", TooltipLong="Thickness of the clamp")
@param(K=LENGTH, TooltipShort="Overall width of the clamp. If set to 0 we use D+(L*2)", TooltipLong="Overall width of the clamp. If set to 0 we use D+(L*2)")
@param(M1=LENGTH, TooltipShort="thread rod diameter", TooltipLong="thread rod diameter")
@param(H=LENGTH, TooltipShort="Distance from clamp center to thread end", TooltipLong="Distance from clamp center to thread end")
@group(Name="meaningless enum")
@enum(1, "align X")
@enum(2, "align Y")
@enum(3, "align Z")

def OSPC001(s, D=116.0, L=30.0, W=4.0, K=0.0, M1=10.0, H=150.0, ID = 'OSPC001', **kw):

#Calculation
R1 = (D / 2.0)
R2 = (R1 + W)
if (K <= 0.0):K = (D + (L * 2.0))
CSW=(M1*1.5)
KWdt = float(CSW * math.tan(aqa.math.asRadiants(30.0)))
BH=(K-D-(2*W))/4
BL=(W*7)

#Create Clamp
o1 = CYLINDER(s, R=R2, H=L, O=0.0).translate((0, 0, -(L / 2.0)))
o2 = BOX(s, L=K, W=L, H=(W * 3.0))
o3 = CYLINDER(s, R=R1, H=L, O=0.0).translate((0, 0, -(L / 2.0)))
o4 = BOX(s, L=K, W=L, H=W)

#create rod
o5=CYLINDER(s, R=M1/2, H=H-R2-M1, O=0.0).translate((0,0,R2+M1)).rotateY(90)

#Unite
o1.uniteWith(o2)
o2.erase()
o1.uniteWith(o5)
o5.erase()
o3.uniteWith(o4)
o4.erase()
o1.subtractFrom(o3)
o3.erase()

#Rotate
o1.rotateY(90)

#Create Clamp Bolts
oB1=CYLINDER(s, R=(L/6), H=BL, O=0.0).translate((0, BH+R2, -(BL / 2.0)))
oB2=CYLINDER(s, R=(L/6), H=BL, O=0.0).translate((0, -(BH+R2), -(BL / 2.0)))

#create clamp nut bottom
oN1 = BOX(s, L=CSW, W=M1, H=KWdt).translate((0, 0, -M1/2-R2))
oN2 = BOX(s, L=CSW, W=M1, H=KWdt).translate((0, 0, -M1/2-R2)).rotateZ(60.0)
oN3 = BOX(s, L=CSW, W=M1, H=KWdt).translate((0, 0, -M1/2-R2)).rotateZ(-60.0)


#Unite
oN1.uniteWith(oN2)
oN2.erase()
oN1.uniteWith(oN3)
oN3.erase()
o1.uniteWith(oN1)
oN1.erase()
o1.uniteWith(oB1)
oB1.erase()
o1.uniteWith(oB2)
oB2.erase()


#Connection Points
s.setPoint((0, 0, 0), (-1, 0, 0))
s.setLinearDimension('H', (0, 0, 0), (0, 0, -H))

0 Likes
Message 4 of 9

Anonymous
Not applicable

can you help check the code,thank you 

0 Likes
Message 5 of 9

h_eger
Mentor
Mentor

The Python script works fine for me

 

2021-06-22_11-09-48.jpg

2021-06-22_11-31-40.jpg

-

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).

Hartmut Eger
Senior Engineer
Anlagenplanung + Elektotechnik
XING | LinkedIn

EESignature



0 Likes
Message 6 of 9

Thimo.Bergen
Enthusiast
Enthusiast

I have looked at the code, I can't see why you will get "UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)" with this code.

What I do see is that there is a possible typing error;
"KWdt = float(CSW * math.tan(aqa.math.asRadiants(30.0)))"
I think it should be;
"KWdt = float(CSW * math.tan(aqa.math.radians(30.0)))"

0 Likes
Message 7 of 9

Thimo.Bergen
Enthusiast
Enthusiast

@h_eger 

Could it be that there is a chinese character being inserted somewhere?

0 Likes
Message 8 of 9

dave.wolfe
Advisor
Advisor
Accepted solution

It looks to me like your folder path has characters that aren't supported by ascii.

Dave Wolfe
Isaiah 57:15

EESignature

Plant 3D Wish list

0 Likes
Message 9 of 9

Anonymous
Not applicable

This is the key ,thank you very much.

0 Likes