Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
Dear all,
I want to rotate rod for handrail . This code that sound is correct, however when I test block. This resolves is not as expected. Actually, I wanna the rod (this yellow color ) to create OY direction with k angle as snapshot below. when I test code both of them is duplicated and create OY with 0 degrees. I don't know this code has the problem but when I replace k =30, etc... with a number, (not parameter assignment). this resolve is correct again , not duplicate rod (this yellow color). Someone can explain for me ?. I tried many ways, but that is duplicate and create with OY with O degree
Thank you in advance!
Solved! Go to Solution.
Solved by nghiabt04. Go to Solution.
you are using integer parameter, k turn to be k = 0 from the calculation (integer parameter will round your result).
It's mean:
C/D = 0.5 but in integer its will round to 0 -> sin(0) = 0, so k = 0.
Solution is using float parameter. Code here:
import aqa.math
import math
from varmain.primitiv import *
from varmain.var_basic import *
from varmain.custom import *
@activate(Group="Support", TooltipShort="Support", TooltipLong="Support", LengthUnit="mm")
@group("MainDimensions")
@group(Name="meaningless enum")
@enum(1, "align X")
@enum(2, "align Y")
@enum(3, "align Z")
def HANDRAIL(s, D = 1200.0, D1=25.0, H=1000.0, H1=30.0 ,Alpha=25.0, Beta=30.0, A=30.0, B=100.0, C=600.0, ID = 'HANDRAIL', **kw):
"""
D = 1200 is integer
D = 1200.0 is float
"""
o1a=CYLINDER(s, R=D/2-D1/2, H=B, O= D/2-D1/2-5).translate((0, 0 ,H1))
o2a = TORUS(s, R1=D/2, R2=D1/2).translate((0, 0,H))
o2b = TORUS(s, R1=D/2, R2=D1/2).translate((0, 0,H/2))
k= math.degrees(math.asin(C/D))
print k
o2c=CYLINDER(s, R=D1/2, H=H, O= 0).translate((0, -D/2 ,0)).rotateZ(-k)
o2c1=CYLINDER(s, R=D1/2, H=H, O= 0).translate((0, -D/2 ,0)).rotateZ(k)
o2c.setColor(2)
o2c1.setColor(2)
N=6
if N>1:
phi=225/(N-1)
FirstAngle = phi/2
No=0
InAngle = FirstAngle
while(No<N):
o3a=CYLINDER(s, R=D1/2, H=H, O= 0).translate((0, -D/2 ,0)).rotateZ(InAngle+45.5)
InAngle= InAngle+ phi
No= No+1
# (TESTACPSCRIPT "HANDRAIL")
I tried and got success.
Can't find what you're looking for? Ask the community or share your knowledge.