Author Topic: Set dimscale using dos_lib listbox selection as scale  (Read 1849 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Set dimscale using dos_lib listbox selection as scale
« on: December 01, 2020, 12:48:14 PM »
Revisiting this attempt.

I believe I need to use (vla-put-scalefactor...but before I do that, I need to associate the picked scale from the list with
dimscale, I think.

Code - Auto/Visual Lisp: [Select]
  1. (defun C:TEST (/ dimsc scl sn1 ss ss2 n)
  2.  
  3.    (setq dimsc (getvar 'dimscale))
  4.    (setq scl (dos_listbox "Scaled TitleBlock" "Choose The Appropriate Scale"
  5.                                 '("4" "8" "12" "16" "24" "48" "96")))
  6.  
  7.    (command "_layer" "unlock" "TBLK_BORD_LINES" "")
  8.    (command "scale" "all" "" "0,0" scl "")
  9.  
  10. ;;I'm sure I'm not even close with my attempt... I get Error: bad argument type: lselsetp "4"
  11. ;;I need to associate the selection from the listbox with dimscale.
  12. ;;and then set the dimscale
  13. ;;vla-put-scalefactor ???
  14.  
  15.   (repeat (setq ss (sslength scl))
  16.   (setq ss2 (vlax-ename->vla-object (ssname scl (setq nn (1- ss)))))
  17.   (setq sn1 (stracase (vla-get-scalefactor ss2)))
  18.   )
  19.    
  20.   (command "_layer" "lock" "TBLK_BORD_LINES" "")
  21.   (princ)
  22. )
J. Logan
ACAD 2018

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

ronjonp

  • Needs a day job
  • Posts: 7528
Re: Set dimscale using dos_lib listbox selection as scale
« Reply #1 on: December 01, 2020, 01:31:10 PM »
See comments below .. you have many many errors:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ dimsc scl sn1 ss ss2 n)
  2.   ;; Why are you saving this ?
  3.   (setq dimsc (getvar 'dimscale))
  4.   (setq scl (dos_listbox
  5.               "Scaled TitleBlock"
  6.               "Choose The Appropriate Scale"
  7.               '("4" "8" "12" "16" "24" "48" "96")
  8.             )
  9.   )
  10.   (command "_layer" "unlock" "TBLK_BORD_LINES" "")
  11.   (command "scale" "all" "" "0,0" scl "")
  12.   ;;I'm sure I'm not even close with my attempt... I get Error: bad argument type: lselsetp "4"
  13.   ;;I need to associate the selection from the listbox with dimscale.
  14.   ;;and then set the dimscale
  15.   ;;vla-put-scalefactor ???
  16.   ;; 'scl' is not a selection set it's a ( string ? ) that is a result of dos_listbox <-don't have the dos functions
  17.   (repeat (setq ss (sslength scl))
  18.           ;; Again here .. no selection set
  19.           ;; (setq ss2 (vlax-ename->vla-object (ssname scl (setq nn (1- ss)))))
  20.           ;; (setq sn1 (stracase (vla-get-scalefactor ss2))) No function 'stracase' AND STRCASE is used on STRINGS the scale returned is a NUMBER
  21.           ;; (cond (vla-put-scalefactor ss2)) This COND has no conditions, might as well use (vla-put-scalefactor ss2) but again no selset
  22.   )
  23.   (command "_layer" "lock" "TBLK_BORD_LINES" "")
  24.   (princ)
  25. )
  26.  
  27. ;; Code revised based on the title of this thread
  28. (defun c:test (/ scl)
  29.   (if (setq scl (dos_listbox
  30.                   "Scaled TitleBlock"
  31.                   "Choose The Appropriate Scale"
  32.                   '("4" "8" "12" "16" "24" "48" "96")
  33.                 )
  34.       )
  35.     (setvar 'dimscale (atof scl))
  36.   )
  37.   (princ)
  38. )
« Last Edit: December 01, 2020, 01:37:21 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jlogan02

  • Bull Frog
  • Posts: 327
Re: Set dimscale using dos_lib listbox selection as scale
« Reply #2 on: December 01, 2020, 01:49:34 PM »
Stop making it look easy, man!

Thanks RonJonP
J. Logan
ACAD 2018

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

ronjonp

  • Needs a day job
  • Posts: 7528
Re: Set dimscale using dos_lib listbox selection as scale
« Reply #3 on: December 01, 2020, 03:24:54 PM »
Stop making it look easy, man!

Thanks RonJonP
I'm glad I got it right .. was just a stab in the dark!  :-D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jlogan02

  • Bull Frog
  • Posts: 327
Re: Set dimscale using dos_lib listbox selection as scale
« Reply #4 on: December 01, 2020, 04:30:39 PM »
Minor issue is that the DimStyle becomes an overridden DimStyle. I didn't consider that
and I might need to apply the change of dimscale to more than one dimension style.

Really at the end of the day, I think I'm taking a shortcut I shouldn't take.
J. Logan
ACAD 2018

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

ronjonp

  • Needs a day job
  • Posts: 7528
Re: Set dimscale using dos_lib listbox selection as scale
« Reply #5 on: December 01, 2020, 05:01:52 PM »
Really at the end of the day, I think I'm taking a shortcut I shouldn't take.
Good for you that you recognize that  8-) ...

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC