CoCreate User Forum

CoCreate User Forum (https://www.cocreateusers.org/forum/index.php)
-   Customization (https://www.cocreateusers.org/forum/forumdisplay.php?f=12)
-   -   Some questions in the code (https://www.cocreateusers.org/forum/showthread.php?t=8255)

kting 11-19-2016 05:23 AM

Some questions in the code
 
4 Attachment(s)
I programed a add-on application to rotate the part with a specified angle value.Follow attachment is the code file:Attachment 1941

In the program the part should be rotate 0.9 degree.Actually,the result is that the part is rotated 51.566202degree.
Attachment 1939Attachment 1940Attachment 1942

However,when I change the code ":push-action (sd-call-cmds (g_test))" to ":push-action (g_test)",the result is that the part is rotated 0.9degree.

I can't understand why produce different results by using function sd-call-cmds and no using it in the program.

Could anybody explain it for me?

How to change the program code to keep the dialog when doing a terminate action and rotate the part a specified angle value in the program?

rvn 11-22-2016 02:16 AM

Re: Some questions in the code
 
Hi Kting,

You need to use radials instead of degrees.
Convert your degrees with (sd-deg-to-rad "angle in degrees") to radials and use this.
Normally this should work.

gr
Ruben

kting 11-23-2016 10:31 PM

Re: Some questions in the code
 
Hi Ruben,

I still did not understand that.
Why should modeling position_pa action take a degree input without using sd-call-cmds and take a radians input using sd-call-cmds in the program?

rvn 11-24-2016 05:45 AM

Re: Some questions in the code
 
Hi Kting

In the normal dialog you give the angle in degrees but in the back (in the code) the angle is converted to radials.
So if you make use of the code with lisp then you should use radials instead of degrees.
Or you need to convert it yourself in the back.

You give in 0.9degree and get 51....degrees. Just to point out what happens here --> 0.9rad = 51,... deg :-).

The only thing you need to put in the code is this:
Code:

(position_pa :part_assembly test_p
                    :rotate :axis :pt_dir fix_pnt1 (first dir1)
                    :rotation_angle (sd-deg-ro-rad 0.9)
                    :done)

And normally this should work perfectly.

kind regards
Ruben

kting 11-25-2016 05:07 PM

Re: Some questions in the code
 
You are right. Thank you very much.

rvn 11-27-2016 03:49 AM

Re: Some questions in the code
 
Quote:

Originally Posted by kting (Post 25954)
You are right. Thank you very much.

No problem at all. Glad I could help.


All times are GMT -8. The time now is 09:54 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.