Author Topic: Not sure I can do what I want with doslib as my dialog ?  (Read 790 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Not sure I can do what I want with doslib as my dialog ?
« on: June 02, 2023, 02:06:52 PM »
A piece of old code I'm resurrecting. I want the chosen dim command to continue like it would without dos lib. Right now I have to hit enter and reselect my dimen type from the dialog to continue with the next dimension.

Code - Auto/Visual Lisp: [Select]
  1. (defun LinDim ( / *error* msg osm clay dimtyp dimsc )
  2.   (defun *error* (msg)
  3.     (if osm
  4.       (setvar 'osmode osm)
  5.     )
  6.     (if (not (member msg '("Function cancelled" "quit / exit abort")))
  7.       (princ (strcat "\nError: " msg))
  8.     )
  9.     (princ)
  10.   )
  11.  
  12.   (setvar 'osmode 0)
  13.   (setvar 'cmdecho 0)
  14.   (setq clay (getvar "clayer"))
  15.   (setvar "Clayer" "DIMEN")
  16.   ;;(setq dim1 (getvar 'dimscale))
  17.  
  18.   (setq dimtyp
  19.         (dos_listbox
  20.                "Dimension"
  21.                "Choose Dimen Type"
  22.                '("Dimlinear"
  23.            "Dimangular"
  24.            "DimOrdinate"
  25.                       )
  26.               )
  27.   )
  28.  
  29.   (setq dimsc (getvar 'dimscale))
  30.   (command "dimscale" dimsc)
  31.   (setq col (getvar 'cecolor))
  32.   (setvar 'cecolor "1")
  33.   (command dimtyp)
  34.  
  35.   (while (< 0 (getvar 'cmdactive)) ;; While the command is active, pause
  36.          (command "\\") ;; Pause for user input
  37.      ) ;; end WHILE
  38.  
  39.  (setvar 'cecolor "bylayer")
  40.  (command "clayer" clay)
  41. )

I'm going to bite the bullet and do a proper dialog box or BigAl's method while I wait for answers here.
That
Code - Auto/Visual Lisp: [Select]
  1. (while... (command "\\")
doesn't seem to be working.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

stevej

  • Newt
  • Posts: 30
Re: Not sure I can do what I want with doslib as my dialog ?
« Reply #1 on: June 03, 2023, 12:47:53 AM »
If I'm reading my resource material correctly, cmdactive will never be less than 0.

Steve

ribarm

  • Gator
  • Posts: 3297
  • Marko Ribar, architect
Re: Not sure I can do what I want with doslib as my dialog ?
« Reply #2 on: June 03, 2023, 02:47:22 AM »
If I'm reading my resource material correctly, cmdactive will never be less than 0.

Steve

I always use this construction - for me quicker for writing and it means : while cmdactive above 0 => loop, and if cmdactive = 0 stop looping... negative numbers are not in concern here as like you stated cmdactive can never be less than 0, but can be 0 which here triggers stopping of loops...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

BIGAL

  • Swamp Rat
  • Posts: 1428
  • 40 + years of using Autocad
Re: Not sure I can do what I want with doslib as my dialog ?
« Reply #3 on: June 03, 2023, 02:52:17 AM »
Rather than dos_lib, in the multi radio buttons you can set which button is turned on so hidden is the answer the variable BUT holds the button last selected.

Code: [Select]
(if (= ahdef nil)(setq ahdef 1))
......
..... do this
(setq ans .......
(setq ahdef but)

So when called again just click OK to accept choice.
A man who never made a mistake never made anything