Author Topic: Adding 2 Options within a baisc routine  (Read 2090 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding 2 Options within a baisc routine
« on: August 13, 2018, 08:48:47 AM »
I have a basic routine that currently erases an aecc object.

Code: [Select]
(defun c:BasicCommand()
(ssget "x" '((0 . "AECC_NETWORK")))
(initcommandversion 2)   
(command "erase" "p" "")
(princ))

But I was wanting to add another option that would allow for exploding the aecc object. Is there a basic way to do this without just having 2 routines. One to do the erase, and the other to do the exploding? (This is what I would have done) lol.
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Adding 2 Options within a baisc routine
« Reply #1 on: August 13, 2018, 05:55:54 PM »
By "add another option", are you looking to prompt the user for whether the object should be erased or exploded?

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Adding 2 Options within a baisc routine
« Reply #2 on: August 13, 2018, 05:57:28 PM »
That's about right. Ask to either do this or that kinda thing.
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Adding 2 Options within a baisc routine
« Reply #3 on: August 13, 2018, 06:24:52 PM »
Use the initget & getkword functions.

Very simply put -
Code - Auto/Visual Lisp: [Select]
  1. (initget "Erase eXplode")
  2. (if (= "Erase" (getkword "\nErase or explode? [Erase/eXplode] <eXplode>: "))
  3.     (progn
  4.         ;;    Code for Erase
  5.     )
  6.     (progn
  7.         ;;    Code for Explode  
  8.     )
  9. )

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Adding 2 Options within a baisc routine
« Reply #4 on: August 13, 2018, 06:32:44 PM »
Awesome Lee! I knew it was basic, just couldn’t find how to do it. Thank you again as usual.
Civil3D 2020

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Adding 2 Options within a baisc routine
« Reply #6 on: August 15, 2018, 03:06:23 PM »
Hey CAB,

Thanks for this... Great info. Dozens of ways to do this. Again Thank you.
Civil3D 2020

ScottMC

  • Newt
  • Posts: 191
Re: Adding 2 Options within a baisc routine
« Reply #7 on: August 16, 2018, 12:24:38 PM »
A thought similar to my post, that, by using the shift/ctrl while a command is active, to get/enable an alternate/desired command activated in a running while loop till action completed. This is exactly what would power and speed drafting.
...do consider using acet-sys-keystate as the comments/code exist.
« Last Edit: September 05, 2018, 03:45:37 PM by ScottMC »