cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

LISP for part rolling a angle by step

bjyuen
7-Bedrock

LISP for part rolling a angle by step

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°.

example-initial position.bmpexample-ran position.bmp

Does anybody could tell me why?

How can I  achieve my purpose to roll 0.9° step by step?


Thanks

Justin


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
ACCEPTED SOLUTION

Accepted Solutions

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.

Creo Element\Direct Modeling 20.6.0.0.0

View solution in original post

13 REPLIES 13
FriedhelmK
17-Peridot
(To:bjyuen)

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

(Please write info in your Signature) Sysinfo: I use Creo Elements Direct /Drafting, /Modeling and /Modeling Express 8.0 ( formerly CoCreate- SolidDesigner and Drafting or ME10 )

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.

22.bmp

Ran the LISP,you could see variable angle_factor_deg value was 0.9.

11.bmp


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

Creo Element\Direct Modeling 20.6.0.0.0

you could also use this line.

:rotation_angle (sd-deg-to-rad .9)

Creo Element\Direct Modeling 20.6.0.0.0

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

Creo Element\Direct Modeling 20.6.0.0.0

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

Creo Element\Direct Modeling 20.6.0.0.0

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

Creo Element\Direct Modeling 20.6.0.0.0

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

bjyuen
7-Bedrock
(To:bjyuen)

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.

Creo Element\Direct Modeling 20.6.0.0.0

Maybe you are right,but I still do not understand it.

Best regards

Justin

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags