CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 04-27-2010, 01:40 AM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
How to make this Lisp loop...

Hi,

I tried all kinds of things, but I cannot make this Lisp loop...
It's basically a tool that we want to use to do a "quick fix" on short edges in models, so that the models can be imported in other CAD systems. It creates a small sphere on the picked point on a model. I'd like to be able to click another point as soon as a sphere has been created, and I tried things like prompt-variable etc., but I'm afraid that I don't fully understand the documentation on this...
Anyone have a good tip on this??
Thanks!
Kind regards,
Jaap

Code:
(in-package :JAAPS_TOOLS)
(use-package :OLI)

(sd-defdialog 'Repair_short_edge
 	:dialog-title "Repair Short Edge"
  
	:variables
 	'(
		(part :value-type :part :title "part")
		(radius :value-type :number :title "radius" :initial-value 0.1)
		(POINT :value-type :point-3d :title "punt" :after-input
			(progn
				(setf draaipunt (sd-vec-add POINT (gpnt3d 0 1 0)))
				(CREATE_WORKPLANE :new :pt_dir :origin POINT :normal :z)
				(line :two_points 0,-0.1 0,0.1)
				(ARC :CEN_RAD_ANG 0,0 0,0.1 0,-0.1 0,0.1)
				(turn :keep_wp :yes :keep_profile :NO :sel_part part :axis :two_pta POINT draaipunt :rotation_angle 360)
				(delete_3d :workplane :current)
			)
		);point
		
     )
)
Reply With Quote
  #2  
Old 04-27-2010, 11:50 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: How to make this Lisp loop...

Quote:
Originally Posted by jkramer View Post
Hi,

I tried all kinds of things, but I cannot make this Lisp loop...
It's basically a tool that we want to use to do a "quick fix" on short edges in models, so that the models can be imported in other CAD systems. It creates a small sphere on the picked point on a model. I'd like to be able to click another point as soon as a sphere has been created, and I tried things like prompt-variable etc., but I'm afraid that I don't fully understand the documentation on this...
Anyone have a good tip on this??
Thanks!
Kind regards,
Jaap
Hi Jaap,

Interesting idea -- Nice!

The reason it doesn't loop is that you need to enclose any modeling operations in (sd-call-cmds ...) -- otherwise it's basically as if you typed them in the user input line, and then they complete and return you to the "enter command" state rather than staying in the dialog.

For the looping, you can just have a line like :next-variable 'point in your code.

So, if we just wrap your lines in (sd-call-cmds ...) and add the :next-variable line and a couple of other changes, we get something like this:
Code:
(in-package :JAAPS_TOOLS)
(use-package :OLI)

(sd-defdialog 'Repair_short_edge
  :dialog-title "Repair Short Edge"
  :variables
  '(
    (part :value-type :part :title "part")
    (radius :value-type :distance :title "radius" :initial-value 0.1)
    (POINT :value-type :point-3d
       :title "punt"
       :after-input
       (let (draaipunt)  ;; create temporary variable
         (setf draaipunt (sd-vec-add POINT (gpnt3d 0 1 0)))
         (sd-call-cmds (CREATE_WORKPLANE :new :pt_dir :origin POINT :normal :z))
         (sd-call-cmds (line :two_points (gpnt2d 0 (- radius)) (gpnt2d 0 radius)))
         (sd-call-cmds
          (turn :keep_wp :yes :keep_profile :NO :sel_part part :axis :two_pta POINT draaipunt :rotation_angle (* 2 pi)))
         (sd-call-cmds(delete_3d :workplane :current))
         )
       :next-variable 'point
       );point
    )
  )
A couple of notes regarding the above:
  • I changed the :value-type to :distance to accommodate any user units (Modeling automatically converts :distance variables to mm internally)
  • I changed the hardcoded .1 values to use the radius variable (using the gpnt2d function to generate a 2D data point since we're using a variable)
  • Similar to the :distance variable, I changed the angle of rotation to 2*pi -- using sd-call-cmds always uses internal units (mm,g,rad)
If we want, we can make it even simpler by letting Modeling do some of the additional work for us, such as when creating the arc and deleting the workplane:
Code:
(in-package :JAAPS_TOOLS)
(use-package :OLI)

(sd-defdialog 'Repair_short_edge
  :dialog-title "Repair Short Edge"
  :variables
  '(
    (part :value-type :part :title "part")
    (radius :value-type :distance :title "radius" :initial-value 0.1)
    (POINT :value-type :point-3d
       :title "punt"
       :after-input
       (progn
         (sd-call-cmds (CREATE_WORKPLANE :new :pt_dir :origin POINT :normal :z))
         ;; draw the line so it is along the u (horizontal) axis
         (sd-call-cmds (line :two_points (gpnt2d (- radius) 0) (gpnt2d radius 0)))
         ;; the ARC command can use a ctr pnt, a radius, a start angle, and a finish angle rather than points
         (sd-call-cmds (arc :cen_rad_ang 0,0 radius 0 pi))
         ;; turn about the u (horizontal) axis and delete WP as part of the turn operation
         (sd-call-cmds (turn :keep_wp :no :sel_part part :axis :u :rotation_angle (* 2 pi)))
         )
       :next-variable 'point
       );point
    )
  )
I hope this helps!

andy
__________________
Andy Poulsen
AI MAXTools: Dream. Design. Done. It's that easy!
Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+!
See them in action at www.ai-maxtools.com and then try them for yourself -- FREE!
Reply With Quote
  #3  
Old 04-27-2010, 10:10 PM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
Re: How to make this Lisp loop...

Hi Andy,

wow, thanks a lot!! This is most helpful!
I finaly understand this awkward sd-call-cmds ;-)
Kind regards,
Jaap
Reply With Quote
  #4  
Old 04-28-2010, 04:40 AM
bobwing bobwing is offline
Registered User
 
Join Date: Oct 2002
Location: Southeastern Mass.
Posts: 45
Re: How to make this Lisp loop...

Jaap, thanks for posting your question, I found it to be very interesting.

Andy, great job explaining the use of SD-CALL-CMDS.

I was also trying to find a solution to this issue as well by modifying and old multicopy/sharedcopy macro which performs a loop style action. I noticed the sd-call-cmds in this macro but I couldn't figure out the correct procedure to call and the recorder wasn't much help.

Other than using the recorder, is there another way of finding valid commands to use with sd-call-cmds, I'm not finding anything in the IKIT documentation.

Thanks,
Bob
__________________

Bob Wing
CAD Manager
Reply With Quote
  #5  
Old 04-28-2010, 07:24 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: How to make this Lisp loop...

Quote:
Originally Posted by bobwing View Post
Other than using the recorder, is there another way of finding valid commands to use with sd-call-cmds, I'm not finding anything in the IKIT documentation.
Well, just about any command you can call interactively can be called using sd-call-cmds -- but keep in mind that using sd-call-cmds only works when calling from a dialog.

Many years ago, CoCreate had an HTML command reference that shipped with each version of SolidDesigner listing the main Modeling commands (i.e. the underlying commands that are called when you click one of the CC menu buttons) and describing the parameters for each one. That was very useful, but became too much work to maintain as a separate document, so they discontinued it.

Even though this reference is no longer maintained, you can at least get a list of most of the defined commands by typing (oli:sd-online-reference) into your user input line. This will insert a button in your toolbox that will show you the list of commands currently defined, and if you click one of those commands, you'll get a list of the parameters for that command (if it has any -- some don't). Unfortunately, a lot of the time you won't know what command to use in a particular situation -- so then it's back the recorder (which is also useful for knowing how to use the various parameters, too)...

So, it's not the ideal situation, but it's much better than nothing!

andy
__________________
Andy Poulsen
AI MAXTools: Dream. Design. Done. It's that easy!
Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+!
See them in action at www.ai-maxtools.com and then try them for yourself -- FREE!
Reply With Quote
  #6  
Old 05-01-2010, 10:09 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Re: How to make this Lisp loop...

using
Code:
 (point :value-type...........
        ........
        :next-variable 'point
         )
is one.. but why not using
Code:
:dialog-control :sequential-loop
your use case is exactly what it is designed for. Give it a try and compare!

--------------------------------------------------------
edit-start

uppppssss - This have not been a good idea by me. :-( I concentrated to much on the loop itself and did not see the 2 other variables. With the loop I suggested there would be no UI at all, but also after each point clicked you would have to specify part and radius again and again. I think this is not the right way for this dialog. -- Sorry for misleading suggestion.

edit-end

Last edited by Wolfgang; 05-03-2010 at 08:21 AM. Reason: misleading suggestion
Reply With Quote
  #7  
Old 05-02-2010, 11:59 PM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
Re: How to make this Lisp loop...

Thanks Wolfgang, I'll try that one!
Regards,
Jaap
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
You Rated this Thread: