Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi~
I programed a LISP for a blank to roll one angle 0.9° step by step.( see the attachment LISP file)
Because position_pa command is a terminate action,so I use sd-call-cmds function in the LISP program.
When I ran the program to roll the part 0.9°,actually rolled angle was 51.566202°.
Does anybody could tell me why?
How can I achieve my purpose to roll 0.9° step by step?
Thanks
Justin
Solved! Go to Solution.
Justin
I am not 100% sure of the answer, I can give a best guess. The calculations are done in lisp which requires radians. Modeling takes a degree input and converts it to radians for calculations.
Hello Justin,
I do not know much about Lisp programming,
but I see the cause in radiant.
1 rad = 180 ° / Pi = 57.295779513082320876798154814105°
° 0.9 = 51.566201561774088789118339332695°
It revolves around 0.9 radiants and not around 0.9°
Best regards
Friedhelm
Friedhelm,
I know that 0.9rad equal 51.566202degree.
In the LISP using position_pa action have to set the angle in degree. So I set a variable angle_factor_deg.
Ran the LISP,you could see variable angle_factor_deg value was 0.9.
Justin
A couple of tips These will replace some of the work you did.
(sd-deg-to-rad angle)
(sd-rad-to-deg angle)
Lisp works in radians despite what units you have set.
So simply change the line from
:rotation_angle angle_factor_deg
to
:rotation_angle angle_factor_rad
regards
Tom
you could also use this line.
:rotation_angle (sd-deg-to-rad .9)
Tom,
I know the function sd-deg-to-rad and sd-rad-to-deg.
In the LISP I defined a function g_test() that can be call to do roll part angle.
When push the button to call this function with " (sd-call-cmds (g_test))",the result is the part roll 51.566202degree.
Change to call the function without sd-call-cmds, the ruslt is the part roll 0.9degree.
I can not understand why produce different results with sd-call-cmds or not.
Justin
This is a question that I am not really qualified to answer. I am not sure what the issue is.
However, since you are defining local functions, you do not need to use sd-call-cmds to call those functions.
Regards
Tom
It could not achieve my purpose to roll a angle by step pushing the accept button in the dailog window.
Because the dailog window would be closed when I called the local functions without using sd-call-cmds.
Best regards.
Justin
I went through the program again.
You are calling a modeling function (position_pa). If you call a modeling command like this, without placing it in the (sd-call-cmds) wrapper, it will run the command stop the current command.
(g_test()
(position_pa :part_assembly test_p
:rotate :axis :pt_dir fix_pnt1 (first dir1)
:rotation_angle angle_factor_deg
:done)
should be
(g_test()
(sd-call-cmds (position_pa :part_assembly test_p
:rotate :axis :pt_dir fix_pnt1 (first dir1)
:rotation_angle angle_factor_deg
:done))
Now you do not have to have the sd-call-cmds to call a local function.
I did some editing on the program for myself.
Regards
Tom
A quick edit.
I used :minimum and :maximum for a not scaled value. I re-wrote the input to check the angle to keep it in the range of -360 to 360.
Regards
Tom
As you suggestion I changed the code and then loaded the program.
Result was the same the part roll angle 51.566202° not 0.9°.
When you delete using sd-call-cmds function in the LISP program, load the program,you will find that the part roll 0.9°.
The question I really want to know is why get difference result to roll part using sd-call-cmds and not using it?
Best regards
Justin
I also found that using sd-call-cmds to call position_pa action you have to assigned :rotation_angle randians value. And not using sd-call-cmds you have to assigned :rotation_angel degree value.You did it the part would be rotated the same angle value.But I really not understand it.
Position_pa action's variable :rotation_angle should be a degree value assigned right?
Best regards
Justin
Justin
I am not 100% sure of the answer, I can give a best guess. The calculations are done in lisp which requires radians. Modeling takes a degree input and converts it to radians for calculations.
Maybe you are right,but I still do not understand it.
Best regards
Justin