CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 08-05-2009, 01:40 PM
HomeBrew_Nation HomeBrew_Nation is offline
Registered User
 
Join Date: Mar 2009
Posts: 25
My first Lisp

I've tried to go through the "intergration kit" and get a few pionters on creating a lisp routine, but have had no luck.
I would like to create a lisp routine that creates geometery from specfied variables in the "sd-defdialog" command, and call modeling commands with "sd-call-cmds" but all the commands from the "sd_avail_cmds.cmd" require a user input to activate, and I cannot get it to work.

so in a nut shell I would like to be able to:

1) specify a diameter-1
2) specify a diameter-2
3) create geometery of diameter-1
4) revolve the geometery around an axis (defalut Y-axis) of diamter-2
5) the resulting part center location determined by user input if possible, otherwise 0,0,0

I am ready to get a 6er of SPATEN to corress my iner german lisp lovin alter ego.

ps anyone who helps me gets an invite to the "octoberfest" party
Reply With Quote
  #2  
Old 08-05-2009, 03:04 PM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: My first Lisp

Hi,

It's not exactly clear to me what you're trying to do, but I'll give it a try...

One good place to start is to use the recorder. To do this type the following in your Modeling command line and press return:
Code:
(load "recorder")
You will now have a button in your toolbox called "Recorder" -- click on this, specify the filename that you want to use for recording, then hit "Start." Manually do all of the commands that you want to have automated, then hit "Stop" and view the resulting file. This will give you a list of the commands required (and which will need to be called using sd-call-cmds ...).

When calling a command using sd-call-cmds, you can't have any user input during the call to that command (as you found out!). The way to do it is to determine the correct parameters for the command, and then request those parameters from the user as part of your dialog. Then, you pass those parameters to the command as part of sd-call-cmds.

Here's a simple example that might help to get you started. It's a simple dialog to let you rename a part or assembly.
Code:
;; tell the lisp reader which package should contain these functions
(in-package :my-package)

;; tell the lisp reader you want to use the standard Modeling
;;   Integration Kit functions
(use-package :oli)

;; now define a test dialog
(sd-defdialog 'ren_test
  ;; define the title of the dialog
  :dialog-title "Simple Rename"
  ;; define the variables to be used in this dialog
  :variables
  '((mypart :value-type :part-assembly
        :title "Object")
    (newname :value-type :string
         :title "New Name")
    (next :push-action (doit))
    )
  ;; define local functions for this dialog
  :local-functions
  '((doit ()
      (sd-call-cmds (change_name_pa :part_asmb mypart
                    :name newname)))
    )
  ;; define what happens when the user clicks "OK"
  :ok-action '(doit)
  )
The "(in-package :my-package)" line is important -- it creates your own private space for your custom functions (rather than running the risk of overwriting other functions that have already been defined).

If you record the commands to change the name of a part, you'll see that the command is change_name_pa and its parameters are :part_asmb and :name. We use that information to create the part of the dialog that actually does the work -- the function doit (which could be called something else, of course). This function uses sd-call-cmds to call the change_name_pa function, with arguments :part_asmb mypart and :name newname.

I hope this helps get you started -- if you have further questions, just ask!

Good luck!

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 08-06-2009, 04:46 AM
HomeBrew_Nation HomeBrew_Nation is offline
Registered User
 
Join Date: Mar 2009
Posts: 25
Re: My first Lisp

Thanks for the help,
But I still cannot get the user input to create geometery and objects
Here is what I have so far:

see attachment,( how do you disable the smiles?)

When I run the recoder function at home, there is a lot less in the file, the option to include motion is not checked, i've included the recorder file of what i would like to do, but I do not know how to use the varables defined in the dialog in the sd-call-cmds
thanks for the assistance
Attached Files
File Type: lsp first_lisp.lsp (893 Bytes, 529 views)
Reply With Quote
  #4  
Old 08-06-2009, 04:48 AM
HomeBrew_Nation HomeBrew_Nation is offline
Registered User
 
Join Date: Mar 2009
Posts: 25
Re: My first Lisp

the recorder file from the above post,
Attached Files
File Type: lsp TONY-1.lsp (43.9 KB, 531 views)
Reply With Quote
  #5  
Old 08-06-2009, 11:28 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Re: My first Lisp

Quote:
Originally Posted by HomeBrew_Nation View Post
Thanks for the help,
see attachment,( how do you disable the smiles?)
When you are in the full editor you should see a check box under Additional Options titled Disable smilies in text (see GIF). This will prevent display of smilies in your LISP code. If you are using the simple editor you have to click Go Advanced to get this option. You can also check this box when editing an existing post to remove the smilies if you forgot.
Attached Thumbnails
Click image for larger version

Name:	Disable_Smilies.gif
Views:	692
Size:	31.9 KB
ID:	1526  
__________________
John Scheffel
Reply With Quote
  #6  
Old 08-06-2009, 11:44 AM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: My first Lisp

Quote:
Originally Posted by HomeBrew_Nation View Post
so in a nut shell I would like to be able to:

1) specify a diameter-1
2) specify a diameter-2
3) create geometery of diameter-1
4) revolve the geometery around an axis (defalut Y-axis) of diamter-2
5) the resulting part center location determined by user input if possible, otherwise 0,0,0
Hint: Attack a smaller problem first if this is your first attempt of writing a Lisp dialog. For instance, write a trivial dialog which accepts two diameters (numbers) as input, then uses those user-supplied values and some hard-coded constants to create some basic geometry. This will teach you how a dialog works and how to accept input from the user. Extending the dialog to the full version from there should then become a snap.

BTW, there are several sample dialogs in the IKIT docs which you can build upon.
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/
Reply With Quote
Reply

Tags
intergration kit sucks, lsip, spaten


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 12:32 PM.



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.