Python Code T Shape Support Modeling

Python Code T Shape Support Modeling

DW-KIM
Advocate Advocate
962 Views
3 Replies
Message 1 of 4

Python Code T Shape Support Modeling

DW-KIM
Advocate
Advocate

hello.

I'm trying to create a T-shaped support using Python code.

The code I wrote is as follows, and it appears in the Spec Editor, but when inserting an item, the message "Geometry can not be generated with the given parameters."
It is written with the error "Can't find symbol for specified part."

Can someone please check what I'm doing wrong in my code?

 

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

@Anonymous(Group="Support", Ports="1", TooltipShort="Tbar", TooltipLong="This is a Custom T Support", LengthUnit="in")
@group("MainDimensions")
@Anonymous(C1=LENGTH, TooltipShort="Width Frame")
@Anonymous(C2=LENGTH, TooltipShort="Middle Frame Height")
@Anonymous(C3=LENGTH, TooltipShort="Frame Thickness C3")
@Anonymous(C4=LENGTH, TooltipShort="Frame Thickness C4")
@Anonymous(C5=LENGTH, TooltipShort="Length")
@Anonymous(D=LENGTH, TooltipShort="Pipe Diameter")

def Tbar(s, C1=4, C2=4, C3=0.125, C4=0.12, C5=8, D=2.5, **kw):
# MISC BOX
# o0 = BOX(s, L=1, H=1, W=1)

# Support itself
o1 = BOX(s, L=C5, W=C1, H=C3).translate(0, 0, -D/2)
o2 = BOX(s, L=C5, W=C4, H=C2).translate(0, 0, -((D/2) - C3)).rotateX(90)

# Unite the components
o1.uniteWith(o2)
o2.erase()

# Set a reference point
s.setPoint((0, 0, 0), (1, 0, 0))

0 Likes
Accepted solutions (2)
963 Views
3 Replies
Replies (3)
Message 2 of 4

DVaquand
Advisor
Advisor
Accepted solution

Hello


Here is the corrected program as well as its representation

 

DVaquand_0-1703233156440.png

 

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

@Anonymous(Group="Support", Ports="1", TooltipShort="Tbar", TooltipLong="This is a Custom T Support", LengthUnit="in")
@group("MainDimensions")
@Anonymous(C1=LENGTH, TooltipShort="Width Frame")
@Anonymous(C2=LENGTH, TooltipShort="Middle Frame Height")
@Anonymous(C3=LENGTH, TooltipShort="Frame Thickness C3")
@Anonymous(C4=LENGTH, TooltipShort="Frame Thickness C4")
@Anonymous(C5=LENGTH, TooltipShort="Length")
@Anonymous(D=LENGTH, TooltipShort="Pipe Diameter")

def Tbar(s, C1=4, C2=4, C3=0.125, C4=0.12, C5=8, D=2.5, **kw):
# MISC BOX
# o0 = BOX(s, L=1, H=1, W=1)

# Support itself
o1 = BOX(s, L=C5, W=C1, H=C3).translate((0, 0, -D/2))
o2 = BOX(s, L=C5, W=C4, H=C2).translate((0, 0, -((D/2) - C3))).rotateX(90)

# Unite the components
o1.uniteWith(o2)
o2.erase()

# Set a reference point
s.setPoint((0, 0, 0), (1, 0, 0))

 

 

== French ==

 

Voici le programme corrigé ainsi que sa représentation

 

Cordialement
Dominique VAQUAND
www.dovaq.fr


Si mon message propose une solution, veuillez cliquer sur "Accepter comme solution"
If my post offers a solution, please click "Accept as Solution"

 

 

Cette publication vous a-t-elle été utile ? N’hésitez pas à attribuer la mention J’aime à cette publication.
Avez-vous obtenu la réponse à votre question ? Cliquez ensuite sur le bouton ACCEPTER LA SOLUTION.

EESignature

0 Likes
Message 3 of 4

DW-KIM
Advocate
Advocate

Oh right. Since I changed that part, the modeling came out anyway. And somehow I ended up creating a T-shaped support.

Fixed the s.setPoint part.

Then please answer one more question.

What functions are the items after s.setpoint referring to?
For example, (0,0,0) seems to be a coordinate.
What do the items behind (1,0,0) represent?

 

@DVaquand 

0 Likes
Message 4 of 4

DVaquand
Advisor
Advisor
Accepted solution

Hello

 

3.2.10 .setPoint 

The modifier function .setPoint  insert a point at position p and set the direction v to the next part inside this point. 

Alternative we can also set a rotation angle a (most needed for elliptical flanges to get the right alignment) 

The argument p and v can be a mPoint, mVector or a 3‐Tupel (x, y, z). 

The rotation angle a has to be given as degree. 

 

a call from Python should be like 

 

obj.setPoint(p,v)

or 

 

obj.setPoint(p,v,a)

 

Cordialement
Dominique VAQUAND
www.dovaq.fr


Si mon message propose une solution, veuillez cliquer sur "Accepter comme solution"
If my post offers a solution, please click "Accept as Solution"

Cette publication vous a-t-elle été utile ? N’hésitez pas à attribuer la mention J’aime à cette publication.
Avez-vous obtenu la réponse à votre question ? Cliquez ensuite sur le bouton ACCEPTER LA SOLUTION.

EESignature