Blank screen when creating new component created using python

Blank screen when creating new component created using python

jeroen.bolwerk
Contributor Contributor
1,388 Views
8 Replies
Message 1 of 9

Blank screen when creating new component created using python

jeroen.bolwerk
Contributor
Contributor

Dear Forum,

 

I have created a visually representing swagelok tee fitting using Python, which gives no errors when using TESTACPSCRIPT (at least on my end). However when I try to create component in the catalog editor it shows a blank screen.

 

I cannot find a solution online. Any ideas what can cause this issue? See code below.

 

Thank you in advance for any tips. 

 

edit:

Changed ports from 2 to 3, since it's a TEE.

edit 2 (23-2-2023):

Changed the second ND2 -> ND3.

 

 

 

 

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

@activate(Group="Tee",	TooltipShort="Swagelok Tee",TooltipLong="Swagelok-Tee",	LengthUnit="mm",Ports=3)
@group(Name="MainDimensions")
#For explaination of the parameters please consult the excel document or Plant3D catalog
#########################################################################################
#DEFINING PARAMETERS - these appear in the catalog editor
#########################################################################################
@param(Port1=LENGTH,TooltipShort="",TooltipLong="1=Union,2=THDM,3=THDF,4=PL")
@param(Port2=LENGTH,TooltipShort="",TooltipLong="1=Union,2=THDM,3=THDF,4=PL")
@param(Port3=LENGTH,TooltipShort="",TooltipLong="1=Union,2=THDM,3=THDF,4=PL")
@param(A1=LENGTH,TooltipShort="",TooltipLong="Length Ax for port 1")
@param(A2=LENGTH,TooltipShort="",TooltipLong="Length Ax for port 2")
@param(A3=LENGTH,TooltipShort="",TooltipLong="Length Ax for port 3")
@param(D1=LENGTH,TooltipShort="",TooltipLong="Length D = Engagement length")
@param(D2=LENGTH,TooltipShort="",TooltipLong="Length D = Engagement length")
@param(D3=LENGTH,TooltipShort="",TooltipLong="Length D = Engagement length")
@param(F=LENGTH,TooltipShort="",TooltipLong="Body thickness. Convert to mm if stated in inches")
@param(ND1=LENGTH,TooltipShort="",TooltipLong="Nominal size connection 1")
@param(ND2=LENGTH,TooltipShort="",TooltipLong="Nominal size connection 2")
@param(ND3=LENGTH,TooltipShort="",TooltipLong="Nominal size connection 3")
@param(SW1=LENGTH,TooltipShort="",TooltipLong="Connection dimension")
@param(SW2=LENGTH,TooltipShort="",TooltipLong="Connection dimension")
@param(SW3=LENGTH,TooltipShort="",TooltipLong="Connection dimension")
#Parameters that need to be in to make it work
@param(OF=LENGTH0,TooltipLong="DO NOT CHANGE")
@group(Name="meaningless enum")
@param(K=ENUM,TooltipLong="DO NOT CHANGE")
@enum(1,"align X")
@enum(2,"align Y")
@enum(3,"align Z")

def Swagelok_Tee(s,
	Port1=1,
	Port2=1,
	Port3=1,
	A1=36,
	A2=36,
	A3=36,
	D1=22.8,
	D2=22.8,
	D3=22.8,
	SW1=22,
	SW2=22,
	SW3=22,
	ND1=12,
	ND2=12,
	ND3=12,
	F=20.6375,
	OF=-1, K=1, **kw):

	# Values we don't want to be able to edit in the spec/catalog editor
	Cyl_H=3
	BNS=4.5		#Body Nut Separator
	A=A1+A2
	mm2in=25.4

	#########################################################################################
	# --- Body
	#########################################################################################
	
	if (0>A<=54):
		BodyL1=A*0.35
	elif (A>54):
		BodyL1=A*0.45
	else:
		BodyL1=50
	BodyL2=(BodyL1-F)
	BodyW=F
	BodyH=BodyW
	Obj_BOX_BodyA=BOX(s, L=BodyL1, W=BodyW, H=BodyH)
	Obj_BOX_BodyB=BOX(s, L=BodyH, W=BodyW, H=BodyL2).translate((F/2, 0, 0))

	Obj_BOX_BodyA.uniteWith(Obj_BOX_BodyB)
	Obj_BOX_BodyB.erase()

	#########################################################################################
	# --- Port 1	direction = Y-
	#########################################################################################
	Port1Angle=90
	if (Port1==2):
		if (ND1>F):	ND1=F
		obj_Cone_1_2=CONE(s, R1=ND1/2, R2=(ND1-1)/2, H=A1/2, E=0.0).rotateX(Port1Angle).translate((0, -A1/2, 0))
		Obj_BOX_BodyA.uniteWith(obj_Cone_1_2)
		obj_Cone_1_2.erase()
		obj_Cyl_1_2=CYLINDER(s, R=ND1/2, H=A1/2, O=0.0).rotateX(Port1Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_1_2)
		obj_Cyl_1_2.erase()
	elif (Port1==3):
		obj_Cyl_1_3=CYLINDER(s, R=F/2, H=A1, O=(F-6)/2).rotateX(Port1Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_1_3)
		obj_Cyl_1_3.erase()
	elif (Port1==4):
		obj_Cyl_1_4=CYLINDER(s,R=ND1/2,H=A1,O=(ND1-3)/2).rotateX(Port1Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_1_4)
		obj_Cyl_1_4.erase()
	else:
		#START NUT 1-----------------------------------------------------------------------------
		N1=SW1/2
		NutL1=N1
		NutW1=SW1
		NutH1=(SW1/2)/sin(radians(60))

		Obj_BOX_Nut1_1=BOX(s,L=NutL1, W=NutW1, H=NutH1)
		Obj_BOX_Nut1_2=BOX(s,L=NutL1, W=NutW1, H=NutH1).rotateY(60)
		Obj_BOX_Nut1_3=BOX(s,L=NutL1, W=NutW1, H=NutH1).rotateY(120)
		Obj_BOX_Nut1_1.uniteWith(Obj_BOX_Nut1_2)
		Obj_BOX_Nut1_2.erase()
		Obj_BOX_Nut1_1.uniteWith(Obj_BOX_Nut1_3)
		Obj_BOX_Nut1_3.erase()
		Obj_BOX_Nut1_1.translate((0, -A1+Cyl_H+NutL1/2, 0))
		#END NUT 1-------------------------------------------------------------------------------
		Obj_Cyl1_L=CYLINDER(s, R=SW1/2, H=Cyl_H, O=ND1/2).rotateX(Port1Angle).translate((0, -A1+Cyl_H, 0))
		Obj_Cyl1_S=CYLINDER(s, R=ND1/2+2, H=A1-NutL1, O=0.0).rotateX(Port1Angle)
		Obj_BOX_BodyA.uniteWith(Obj_Cyl1_L)
		Obj_Cyl1_L.erase()
		Obj_BOX_BodyA.uniteWith(Obj_Cyl1_S)
		Obj_Cyl1_S.erase()
		Obj_BOX_BodyA.uniteWith(Obj_BOX_Nut1_1)
		Obj_BOX_Nut1_1.erase()
	s.setPoint((0, -A1+D1, 0), (0, -1, 0))


	#########################################################################################
	# --- Port 2	direction = Y+
	#########################################################################################
	Port2Angle=-90
	if (Port2==2):
		if (ND2>F):	ND2=F
		obj_Cone_2_2=CONE(s, R1=ND2/2, R2=(ND2-1)/2, H=A2/2, E=0.0).rotateX(Port2Angle).translate((0, A2/2, 0))
		Obj_BOX_BodyA.uniteWith(obj_Cone_2_2)
		obj_Cone_2_2.erase()
		obj_Cyl_2_2=CYLINDER(s, R=ND2/2, H=A2/2, O=0.0).rotateX(Port2Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_2_2)
		obj_Cyl_2_2.erase()
	elif (Port2==3):
		obj_Cyl_2_3=CYLINDER(s, R=F/2, H=A2, O=(F-6)/2).rotateX(Port2Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_2_3)
		obj_Cyl_2_3.erase()
	elif (Port2==4):
		obj_Cyl_2_4=CYLINDER(s,R=ND1/2,H=A1,O=(ND1-3)/2).rotateX(Port2Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_2_4)
		obj_Cyl_2_4.erase()
	else:
		#START NUT 2-----------------------------------------------------------------------------
		N2=SW2/2
		NutL2=N2
		NutW2=SW2
		NutH2=(SW2/2)/sin(radians(60))

		Obj_BOX_Nut2_1=BOX(s, L=NutL2, W=NutW2, H=NutH2)
		Obj_BOX_Nut2_2=BOX(s, L=NutL2, W=NutW2, H=NutH2).rotateY(60)
		Obj_BOX_Nut2_3=BOX(s, L=NutL2, W=NutW2, H=NutH2).rotateY(120)
		Obj_BOX_Nut2_1.uniteWith(Obj_BOX_Nut2_2)
		Obj_BOX_Nut2_2.erase()
		Obj_BOX_Nut2_1.uniteWith(Obj_BOX_Nut2_3)
		Obj_BOX_Nut2_3.erase()
		Obj_BOX_Nut2_1.rotateZ(180).translate((0, A2-Cyl_H-NutL2/2, 0))
		#END NUT 2-------------------------------------------------------------------------------
		Obj_Cyl2_L=CYLINDER(s, R=SW2/2, H=Cyl_H, O=ND2/2).rotateX(Port2Angle).translate((0, A2-Cyl_H, 0))
		Obj_Cyl2_S=CYLINDER(s, R=ND2/2+2, H=A2-NutL2, O=0.0).rotateX(Port2Angle)
		Obj_BOX_BodyA.uniteWith(Obj_Cyl2_L)
		Obj_Cyl2_L.erase()
		Obj_BOX_BodyA.uniteWith(Obj_Cyl2_S)
		Obj_Cyl2_S.erase()
		Obj_BOX_BodyA.uniteWith(Obj_BOX_Nut2_1)
		Obj_BOX_Nut2_1.erase()
	s.setPoint((0, A2-D2, 0), (0, 1, 0))

	#########################################################################################
	# --- Port 3	direction = X+
	#########################################################################################
	Port3Angle=90
	if (Port3==2):
		if (ND3>F):	ND3=F
		obj_Cone_3_2=CONE(s, R1=ND3/2, R2=(ND3-1)/2, H=A3/2, E=0.0).rotateY(Port3Angle).translate((A3/2, 0, 0))
		Obj_BOX_BodyA.uniteWith(obj_Cone_3_2)
		obj_Cone_3_2.erase()
		obj_Cyl_3_2=CYLINDER(s, R=ND3/2, H=A3/2, O=0.0).rotateY(Port3Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_3_2)
		obj_Cyl_3_2.erase()
	elif (Port3==3):
		obj_Cyl_3_3=CYLINDER(s, R=F/2, H=A3, O=(F-6)/2).rotateY(Port3Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_3_3)
		obj_Cyl_3_3.erase()
	elif (Port3==4):
		obj_Cyl_3_4=CYLINDER(s,R=ND1/2,H=A1,O=(ND1-3)/2).rotateY(Port3Angle)
		Obj_BOX_BodyA.uniteWith(obj_Cyl_3_4)
		obj_Cyl_3_4.erase()
	else:
		#START NUT 3-----------------------------------------------------------------------------
		N3=SW3/2
		NutL3=N3
		NutW3=SW3
		NutH3=(SW3/2)/sin(radians(60))

		Obj_BOX_Nut3_1=BOX(s, L=NutL3, W=NutW3, H=NutH3)
		Obj_BOX_Nut3_2=BOX(s, L=NutL3, W=NutW3, H=NutH3).rotateY(60)
		Obj_BOX_Nut3_3=BOX(s, L=NutL3, W=NutW3, H=NutH3).rotateY(120)
		Obj_BOX_Nut3_1.uniteWith(Obj_BOX_Nut3_2)
		Obj_BOX_Nut3_2.erase()
		Obj_BOX_Nut3_1.uniteWith(Obj_BOX_Nut3_3)
		Obj_BOX_Nut3_3.erase()
		Obj_BOX_Nut3_1.rotateZ(90).translate((A3-Cyl_H-NutL3/2, 0, 0))
		#END NUT 3-------------------------------------------------------------------------------
		Obj_Cyl3_L=CYLINDER(s, R=SW3/2, H=Cyl_H, O=ND3/2).rotateY(Port3Angle).translate((A3-Cyl_H, 0, 0))
		Obj_Cyl3_S=CYLINDER(s, R=ND3/2+2, H=A3-NutL3, O=0.0).rotateY(Port3Angle)
		Obj_BOX_BodyA.uniteWith(Obj_Cyl3_L)
		Obj_Cyl3_L.erase()
		Obj_BOX_BodyA.uniteWith(Obj_Cyl3_S)
		Obj_Cyl3_S.erase()
		Obj_BOX_BodyA.uniteWith(Obj_BOX_Nut3_1)
		Obj_BOX_Nut3_1.erase()
	s.setPoint((A3-D3, 0, 0), (1, 0, 0))

 

 

 

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

h_eger
Mentor
Mentor

Plant 3D 20??

-

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 3 of 9

jeroen.bolwerk
Contributor
Contributor
Plant3D 2022
Product version P3D_S051.02
0 Likes
Message 4 of 9

dave.wolfe
Advisor
Advisor

Did you already create the accompanying images for the script? https://adndevblog.typepad.com/autocad/2015/07/custom-python-scripts-for-autocad-plant-3d-part-4.htm...

Dave Wolfe
Isaiah 57:15

EESignature

Plant 3D Wish list

0 Likes
Message 5 of 9

jeroen.bolwerk
Contributor
Contributor
Yes, I have. I have made an elbow and union-connector already, which work fine.

I have compared the code which work and which do not to see stuff I could have missed.. But yeah, I do not understand.

I have also deleted the __pycache__ and the xml file and re-registered the script to no avail.
0 Likes
Message 6 of 9

h_eger
Mentor
Mentor

Dear @jeroen.bolwerk ,

 

are you sure your TEE has only 2 ports or 3?

Ports=2

 

-

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



Message 7 of 9

jeroen.bolwerk
Contributor
Contributor
Well.. No. It has 3 ports! Thanks for pointing that out!

I have edited this in the script but this does not seem to make a difference regarding the catalog editor.
0 Likes
Message 8 of 9

matt.worland
Advisor
Advisor
Accepted solution

I think there is something off with your parameters. I noticed a typo on line 25 that should be ND3, that should get it running

If my reply was helpful, please give a "Thumbs Up" or "Accept as Solution"
Message 9 of 9

jeroen.bolwerk
Contributor
Contributor

@matt.worland

That did it. Many thanks!

0 Likes