How to fix Python Scripting invalid syntax

How to fix Python Scripting invalid syntax

traiduong014969
Collaborator Collaborator
1,462 Views
9 Replies
Message 1 of 10

How to fix Python Scripting invalid syntax

traiduong014969
Collaborator
Collaborator

Hi all, 

I'm trying to make my first custom part insulation Ebow with python.

Following AUTODESK UNIVERSITY Annex B: Creating Custom Component Scripts in Plant 3D as guide document.

I have created my python script, but when I use PLANTREGISTERCUSTOMSCRIPTS, it shows the following:

Command: PLANTREGISTERCUSTOMSCRIPTS

SyntaxError: invalid syntax

Here my this code :

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

def activate(Group, Ports, TooltipShort, TooltipLong, LengthUnit):
pass


@Anonymous(Group="Fittings", TooltipShort="Elbow Insulation", TooltipLong="Insulation Elbow", LengthUnit="mm")
@group("MainDimensions")
@Anonymous(D=LENGTH, TooltipShort="Radius of Elbow")
@Anonymous(R=LENGTH, TooltipShort="Bend Radius")
@Anonymous(A=ANGLE, TooltipShort="Bend Angle")
@Anonymous(S=LENGTH, TooltipShort="Number of Segments")
@group(Name="meaningless enum")
@enum(1, "align X")
@enum(2, "align Y")
@enum(3, "align Z")

def Insulation_Elbow(s, D1 = 120.0, R1 = 152.0, A1 = 90.0, ID = 'Insulation_Elbow', **kw):
s=ARC3DS(s, D=D1, R=R1 , A=A1 S=S1 ).translate((0, 0, H / 2.0)).rotateZ(90.0)
s.setPoint((0.0, 0.0, 0.0), (-1.0, 0.0, 0.0), 0 , 0.0, D)
return

Can you help me? I'm trying to modify the script but with no success.

 

0 Likes
Accepted solutions (3)
1,463 Views
9 Replies
Replies (9)
Message 2 of 10

rajendra.prajapat
Advisor
Advisor

@traiduong014969 please use attached file.

 

 

 

 

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

h_eger
Mentor
Mentor

Dear @traiduong014969 ,

 

S1 is not defined

def Insulation_Elbow (s, D1 = 120.0, R1 = 152.0, A1 = 90.0, ID = 'Insulation_Elbow', **kw):

 

S=S1 is requested but not available 

s=ARC3DS(s, D=D1, R=R1 , A=A1 S=S1 )

 

 

-

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 4 of 10

traiduong014969
Collaborator
Collaborator

Dear sir, I follow as you guide.

command: PLANTREGISTERCUSTOMSCRIPTS. It's ok. However when i do the next step with command "(TESTACPSCRIPT "Insulation_Elbow") ". It appears with a error as show. I don't know how to fix it. This is my code  appdate 

traiduong014969_1-1634487733213.png

 

0 Likes
Message 5 of 10

rajendra.prajapat
Advisor
Advisor
Accepted solution

@traiduong014969  please use attched script.Capture.PNG

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

traiduong014969
Collaborator
Collaborator

APPDATE:

I have edited again this code as below. It's working. However when I add some code to set the connection port for elbow. It appears an error as shown. I don't understand much about how to set coordinates for the connection point. So @h_eger can help me repair it. Many thank for your help.

traiduong014969_0-1634527179974.png

ok.png

This code working:

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

@Anonymous(Group="Vessel", TooltipShort="Elbow", TooltipLong="Test Box as a Elbow", LengthUnit="mm")
@group("MainDimensions")
@Anonymous(D1=LENGTH, TooltipShort="Radius")
@Anonymous(R1=LENGTH, TooltipShort="Bend radius")
@Anonymous(A1=ANGLE, TooltipShort="Angle Elbow")
@group(Name="meaningless enum")
@enum(1, "align X")
@enum(2, "align Y")
@enum(3, "align Z")

def Elbow(s, D1 = 100.0, R1 = 800.0, A1 = 90, ID = 'Elbow', **kw):
ARC3D(s, D=D1, R=R1, A=A1)

 

This code with error

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

@Anonymous(Group="Vessel", TooltipShort="Elbow", TooltipLong="Test Box as a Elbow", Ports="2", LengthUnit="mm")
@group("MainDimensions")
@Anonymous(D1=LENGTH, TooltipShort="Radius")
@Anonymous(R1=LENGTH, TooltipShort="Bend radius")
@Anonymous(A1=ANGLE, TooltipShort="Angle Elbow")
@group(Name="meaningless enum")
@enum(1, "align X")
@enum(2, "align Y")
@enum(3, "align Z")

def Elbow(s, D1 = 100.0, R1 = 800.0, A1 = 90, ID = 'Elbow', **kw):
ARC3D(s, D=D1, R=R1, A=A1)
s.setPoint((0, 0, 0), (0, 0, -1))
s.setPoint((0, 0, R1), (0, 0, 1))

 

0 Likes
Message 7 of 10

traiduong014969
Collaborator
Collaborator
so, if i want to add connection point to elbow that i will make a catalogue. So how to do it. I don't understand much about how to set coordinates for the connection point. You can edit this code again with add point connection. May thank for your help !
0 Likes
Message 8 of 10

rajendra.prajapat
Advisor
Advisor
Accepted solution

@traiduong014969 you can use below connection point

 

s.setPoint((0, 0, 0), (0, 0, -1))
s.setPoint((0, 0, R1), (0, 0, 1))

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).
0 Likes
Message 9 of 10

hyrro_velasquez
Advocate
Advocate
Accepted solution

@traiduong014969 

good day, hope this helps.

if this helps you pls accept it as a solution.

ElbowConnectionPoints.PNG

Message 10 of 10

traiduong014969
Collaborator
Collaborator

Thank you for your help , So i have some issues that want to ask you like the snapshot below.

With number 3, I see some reference scripts on google have add this component. I don't know what does it mean. Can you explain for me?

traiduong014969_0-1634623427420.png

 

0 Likes