HOW TO MAKE POINT CONECTION ALWAYS PERPENDICULAR TO THE PLANE WHEN CHANGING ANGLE ?

HOW TO MAKE POINT CONECTION ALWAYS PERPENDICULAR TO THE PLANE WHEN CHANGING ANGLE ?

traiduong014969
Collaborator Collaborator
960 Views
5 Replies
Message 1 of 6

HOW TO MAKE POINT CONECTION ALWAYS PERPENDICULAR TO THE PLANE WHEN CHANGING ANGLE ?

traiduong014969
Collaborator
Collaborator

Hi all,

I am beginning to create basic shapes with script . So when I create the elbow. It's has some problem appear with point connection. With A1=90 degrees. It's fine, however when I edit with A1=45 degrees. The point connection incorrect as show (point connection not perpendicular with elbow). I want to make a elbow with angle parameter. But I only create them when its has 90 degrees. Someone know this problem, please  explain for me. Thank you for your support !

traiduong014969_0-1634655088588.png

traiduong014969_1-1634655169265.png

This is my code:

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

@Anonymous(Group="Elbow", TooltipShort="Elbow Insulation", TooltipLong="Insulation Elbow", Ports="2", LengthUnit="mm")
@group("MainDimensions")
@Anonymous(D1=LENGTH, TooltipShort="Radius of Elbow")
@Anonymous(R1=LENGTH, TooltipShort="Bend Radius")
@Anonymous(A1=ANGLE, TooltipShort="Bend Angle")
@Anonymous(S1=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, S1=4, ID = 'Insulation_Elbow', **kw):
o1 = ARC3DS(s, D=D1, R=R1 , A=A1, S=S1 )

s.setPoint((cos(A1)*R1, 0, 0), (cos(A1), 0, 0))
s.setPoint((0, cos(A1)*R1, 0), (0, cos(A1), 0))

 

 

 

0 Likes
961 Views
5 Replies
Replies (5)
Message 2 of 6

ken.fauver
Advocate
Advocate

I recommend using an existing elbow script (see attached zip file) and making changes to it. This will also allow you to see how the elbows are scripted and help with your coding.

Message 3 of 6

rajendra.prajapat
Advisor
Advisor

@traiduong014969 please use the formula in give sanpshot. then use B & C value in setpoint as per geometry.Capture.PNG

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

traiduong014969
Collaborator
Collaborator

Thank for your reply. 

I have converted the formular follow your guide to R value


Adeg=asRadiants(A1)
Bdeg=asRadiants(A2)
A2=180-(A1/2)
C=R1*sin(Adeg)/sin(Bdeg) ---> R1= C*sin(Bdeg)/sin(Adeg)
B=R1*2*sin(Adeg)-----> R1= B/(2*sin(Adeg))

so i get  the value as show:

s.setPoint((C*sin(Bdeg)/sin(Adeg), 0, 0), (1, 0, 0))
s.setPoint((0, B/(2*sin(Adeg)), 0), (0, 1, 0))

And i use command ''PLANTREGISTERCUSTOMSCRIPTS'' . It's ok but with command ''(TESTACPSCRIPT "Insulation_Elbow")'' . It's appear an error

traiduong014969_0-1634743060917.png

I don't know i have convert setpoint value is correct or incorrect?

Please help me ! 

0 Likes
Message 5 of 6

rajendra.prajapat
Advisor
Advisor

@traiduong014969 use the formula as it as. And use below setpoint.

 

s.setPoint((C, 0, 0), (1, 0, 0))
s.setPoint((0, B, 0), (0, 1, 0))

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

traiduong014969
Collaborator
Collaborator

Yes, I have just tested code with setpoint that you guide. However I still see this an error as snaphot. I think that have a error what i have not found yet

traiduong014969_0-1634747991830.png

This is my code: 

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

@Anonymous(Group="Elbow", TooltipShort="Elbow Insulation", TooltipLong="Insulation Elbow", Ports="2", LengthUnit="mm")
@group("MainDimensions")
@Anonymous(D1=LENGTH, TooltipShort="Radius of Elbow")
@Anonymous(R1=LENGTH, TooltipShort="Bend Radius")
@Anonymous(A1=ANGLE, TooltipShort="Bend Angle")
@Anonymous(S1=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, S1=4, ID = 'Insulation_Elbow', **kw):
o1 = ARC3DS(s, D=D1, R=R1 , A=A1, S=S1 )

Adeg=asRadiants(A1)
Bdeg=asRadiants(A2)
A2=180-(A1/2)
C=R1*sin(Adeg)/sin(Bdeg)
B=R1*2*sin(Adeg)

s.setPoint((C, 0, 0), (1, 0, 0))
s.setPoint((0, B, 0), (0, 1, 0))

0 Likes