Author Topic: resetting values  (Read 3545 times)

0 Members and 1 Guest are viewing this topic.

AfricaAD

  • Guest
resetting values
« on: May 06, 2005, 01:42:40 PM »
Need help resetting the value on this itty bitty code:

Code: [Select]

(defun C:RBS3 ()
  (setq plw (getvar "plinewid"))
  (command "plinewid" ".375")
  (command "pline")
  (command "plinewid" plw)
)


How do I get the last line to continue after the pline has been completed? I am assuming I need more code along the pline command?

Thanks!

whdjr

  • Guest
Re: resetting values
« Reply #1 on: May 06, 2005, 02:04:57 PM »
Code: [Select]

(defun C:RBS3 ()
  (setq plw (getvar "plinewid"))
  (setvar "plinewid" 0.375)
  (command "pline")
  (setvar "plinewid" plw)
)

The trick would be to use 'setvar' to set the variable.

To make it more versitile you could do this:
Code: [Select]

(defun C:RBS3 (num / plw)
  (setq plw (getvar "plinewid"))
  (setvar "plinewid" num)
  (command "pline")
  (setvar "plinewid" plw)
)


usage:(buttons or command line)
command:(c:rbs3 0.375)
or
command:(c:rbs3 1)
or
command:(c:rbs3 20)

****edit
This will not really do anything because you are setting the width of your pline before you start the command and then resetting the width before you pick any points.  So your code really doesn't do anything.

daron

  • Guest
resetting values
« Reply #2 on: May 06, 2005, 02:17:12 PM »
actually, the trick would be to finish the code in pline command as AAD guessed. The reason you'd have the problem in the first place is the fact that you're passing control to the user and not taking it back. There are a few threads based on continuing the pline generation so control is passed back to the computer after the user finishes, thus allowing setvar or the next command to do its job.

daron

  • Guest
resetting values
« Reply #3 on: May 06, 2005, 02:20:19 PM »
Upon closer examination, it might not be a good idea to set an argument in this function. It just might confuse the issue and it's far less versitile to type (c:rbs3 0.353) than rbs3.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
resetting values
« Reply #4 on: May 06, 2005, 03:04:35 PM »
This sure could use some error checking.
Code: [Select]
(defun C:RBS3 ()
  (setq plw (getvar "plinewid"))
  (setvar "plinewid" 0.375)
  (command "pline")
  (while (>(getvar "CMDACTIVE")0) (command pause) )
  (setvar "plinewid" plw)
)
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.

daron

  • Guest
resetting values
« Reply #5 on: May 06, 2005, 03:06:25 PM »
Oh yeah, error checking.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: resetting values
« Reply #6 on: May 06, 2005, 03:11:55 PM »
Quote from: AfricaAD
Need help resetting the value on this itty bitty code:

Code: [Select]

(defun C:RBS3 ()
  (setq plw (getvar "plinewid"))
  (command "plinewid" ".375")
  (command "pline")
  (command "plinewid" plw)
)


How do I get the last line to continue after the pline has been completed? I am assuming I need more code along the pline command?

Thanks!

I'm reading your question different, so my suggestion is different. Here's some food for thought:

Code: [Select]
(defun C:RBS3 ( / restore )

    (setq restore
        (mapcar
           '(lambda ( pair / name existing )
                (setq existing
                    (getvar
                        (setq name (car pair))
                    )
                )
                (setvar name (cdr pair))
                (cons name existing)
            )
           '(   ("plinewid" . 0.375)
                ("cmdecho" . 1)
            )
        )    
    )
   
    (command ".pline")
    (while (< 0 (getvar "cmdactive")) ;; my guess is that this
        (command pause)               ;; is the bit you're actually
    )                                 ;; interested in
   
    (foreach pair restore
        (setvar
            (car pair)
            (cdr pair)
        )
    )
   
    (princ "<energizer bunny> Still going ... boom boom boom ... <done>.\n")
    (princ)
   
)

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AfricaAD

  • Guest
resetting values
« Reply #7 on: May 06, 2005, 03:33:11 PM »
Code: [Select]

(while (>(getvar "CMDACTIVE")0) (command pause) )


That was it!

Thanks! CAB.

MP, is that in English? That coding is too advanced for me bro.  :wink:

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
resetting values
« Reply #8 on: May 06, 2005, 03:41:16 PM »
No, it's lisp. Take your time, it may be new to you, but it's not advanced. It's functionally equivalent to this --

Code: [Select]
(defun C:RBS3 ( / plinewid cmdecho )

    (setq
        cmdecho  (getvar "cmdecho")
        plinewid (getvar "plinewid")
    )
   
    (setvar "cmdecho" 1)
    (setvar "plinewid" 0.375)

    (command ".pline")
    (while (< 0 (getvar "cmdactive")) ;; my guess is that this
        (command pause)               ;; is the bit you're actually
    )                                 ;; interested in
   
    (setvar "cmdecho" cmdecho)
    (setvar "plinewid" plinewid)
   
    (princ "<energizer bunny> Still going ... boom boom boom ... <done>.\n")
    (princ)
   
)

Just a different take to make you go "hmmm".

IOW: What good is the place if it doesn't make you stretch your wings and take flight?

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
resetting values
« Reply #9 on: May 06, 2005, 05:28:36 PM »
Quote from: MP

IOW: What good is the place if it doesn't make you stretch your wings and take flight?
:)

Just when the nest was starting to feel like home, too, and besides, it's sooooo cooooldd out there in the rarified air that you breath  :twisted:

whdjr

  • Guest
resetting values
« Reply #10 on: May 09, 2005, 10:04:53 AM »
Code: [Select]
(while (>(getvar "CMDACTIVE")0) (command pause) )

WOW!!!  So basic yet so powerful.  Thanks for the reminder guys. :)