Jump to content

options within a lisp


Rooster

Recommended Posts

Perfect! So i was correct. The above code model is not good for you. I suggest that you develop some pseudo code.

 

Pseudo code is very easy to do; write down in plain English what you want to accomplish step by step. -e.g.

Prompt user for scale factor
Grab all text from the drawing
       determine the scale of text
build a list of all text entities which need to be altered
Iterate the list and scale text entities as necessary based upon end users scale prompt
Ensure that paper space is active
       switch to paper space if necessary
...

 

This logic is difficult and you will/should revise it several times before you produce any code. the actual code is the easy part --i should say tedious part-. develop flow and think of counter actions and how the users will can break the chain of operations. Doing this will give you a very good head start.

Link to comment
Share on other sites

I think I'll let Se7en take this one, as he seems to know more about putting things on shelves than I do... o:)

 

Sorry, i dont give people fish. I wont be doing much more then giving out pieces, snipits, and such. Rarely, i will revamp an app but i almost never give out a full fledged working version. I learned that lesson a long time ago.

Link to comment
Share on other sites

Sorry, i dont give people fish. I wont be doing much more then giving out pieces, snipits, and such. Rarely, i will revamp an app but i almost never give out a full fledged working version. I learned that lesson a long time ago.

 

Maybe I should start to do the same - you start to give, and people never stop taking...

Link to comment
Share on other sites

Perfect! So i was correct. The above code model is not good for you. I suggest that you develop some pseudo code.

 

Pseudo code is very easy to do; write down in plain English what you want to accomplish step by step. -e.g.

Prompt user for scale factor
Grab all text from the drawing
       determine the scale of text
build a list of all text entities which need to be altered
Iterate the list and scale text entities as necessary based upon end users scale prompt
Ensure that paper space is active
       switch to paper space if necessary
...

This logic is difficult and you will/should revise it several times before you produce any code. the actual code is the easy part --i should say tedious part-. develop flow and think of counter actions and how the users will can break the chain of operations. Doing this will give you a very good head start.

 

I'd just like to re-iterate just how useful this is. When I write a program and I'm stuck and overwhelmed at what it is I'm about to do, and I'm trying to piece everything together in my head, it helps a LOT to just hit a semi-colon and start jotting down notes in the code itself, breaking it up into manageable bits, just as you see here. This is always good practice in everything you do, not just coding. It really, really does help a lot.

Link to comment
Share on other sites

Maybe I should start to do the same - you start to give, and people never stop taking...

 

yeah that's one of the reasons along with appreciation, understanding, maintenance, etc., etc., blah, blah, blah.

 

...I'm up front and honest about it; I wont give you a full fledged program. I may give you 90% or 10% but its up to you do do the work. But on that same note, i give away everything i do that is worth anything.

Link to comment
Share on other sites

Maybe I should start to do the same - you start to give, and people never stop taking...

 

I just want to point out that I'm not here to take advantage of everybody's generosity in helping me out. lee especially has helped me a number of times & I greatly appreciate it. I'm not asking anyone to write my entire lisp for me - I'm just coming here when I encounter problems to get some help. Who knows, maybe one day I'll know enough about it all to help someone out myself.....

Link to comment
Share on other sites

I just want to point out that I'm not here to take advantage of everybody's generosity in helping me out. lee especially has helped me a number of times & I greatly appreciate it. I'm not asking anyone to write my entire lisp for me - I'm just coming here when I encounter problems to get some help. Who knows, maybe one day I'll know enough about it all to help someone out myself.....

 

No, no one is thinking that! We are on a forum. We wouldn't post or be here if we didn't want to help. We were just talking about the ``teach a man to fish...'' adage.

Link to comment
Share on other sites

I just want to point out that I'm not here to take advantage of everybody's generosity in helping me out. lee especially has helped me a number of times & I greatly appreciate it. I'm not asking anyone to write my entire lisp for me - I'm just coming here when I encounter problems to get some help. Who knows, maybe one day I'll know enough about it all to help someone out myself.....

 

Of course Rooster - I'm not pointing the finger here - just from experience, that is the impression you get.

Link to comment
Share on other sites

  • 14 years later...

I am trying to piece together the rest of the code from the above.

 

(or *ans* (setq *ans* "A"))
(initget "A B C")
(or (not
     (setq ans
       (getkword
         (strcat "\nSelect a Letter [A/B/C] <" *ans* ">: "))))
   (setq *ans* ans))

 

I then saw the Dynamic Input on Lee's website.

(if (null global:ans)
    (setq global:ans "Alpha")
)
(initget "Alpha Beta Gamma")
(if (setq tmp (getkword (strcat "\nChoose [Alpha/Beta/Gamma] <" global:ans ">: ")))
    (setq global:ans tmp)
)


I am trying to piece it together but I am not able to get it to work. Any ideas?

 

(defun c:test1 (/ global ans tmp)
  (if (null global:ans)
      (setq global:ans "30")
  )
  (initget "10 20 30")
  (if (setq tmp (getkword (strcat "\nChoose [10/20/30] <" global:ans ">: ")))
      (setq global:ans tmp)
  )
  (cond
    ((eq tmp "10")
      (alert "... Do something 10 ...")
    )
    ((eq tmp "20")
      (alert "... Do something 20 ...")
    )
    ((eq tmp "30")
      (alert "... Do something 30 ...")
    )
  )
  (princ))

 

Thanks for any help!

Link to comment
Share on other sites

19 minutes ago, rcb007 said:

I am trying to piece it together but I am not able to get it to work. Any ideas?

I think you're just missing one small part:

(if (setq tmp (getkword (strcat "\nChoose [10/20/30] <" global:ans ">: ")))
      (setq global:ans tmp)
      (setq tmp global:ans);<-Add this to set tmp variable to the default variable if the user just hits ENTER.
  )

 

Edited by pkenewell
  • Like 1
Link to comment
Share on other sites

Thank you for the help!! Thank you for pointing our the one line I missed. Lee, I like simple. ;)

 

One other question. How would you save the variable to a users windows profile? 

(If the user would to close cad completely. Then restart and run the command again.)

How would you set same value as the above's routine?

Link to comment
Share on other sites

Consider using either the setenv & getenv functions, or saving the values to a plain text file (e.g. .cfg).

Link to comment
Share on other sites

Your welcome to use this replaces initget. There is examples at top of code, save the file to a support directory as you must use (load "multi radio buttons")

 

(setq ans (ah:butts 1 "V"   '("A B C D " "A" "B" "C" "D" )))

(setq ans (atoi (ah:butts 1 "V"   '("Please choose " "10" "20" "30" "40" ))))

image.png.a4d0ed556f1b9ca38cee86e5201b3bf5.png

Multi radio buttons.lsp

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...