Code Red > AutoLISP (Vanilla / Visual)

Dimstyle Applying..

(1/1)

hardwired:
Hi,

I have the following simple lisp routine to flick between certain dimstyles a little quicker and easier:



--- Code: ---; SET STD-2 DIMSTYLE..
(defun C:2 ()
  (command "-dimstyle" "R" "ABI-2")
  )
; SET STD-2.5 DIMSTYLE..
(defun C:2-5 ()
  (command "-dimstyle" "R" "ABI-2-5")
  )
; SET STD-5 DIMSTYLE..
(defun C:5 ()
  (command "-dimstyle" "R" "ABI-5")
  )
; SET STD-10 DIMSTYLE..
(defun C:10 ()
  (command "-dimstyle" "R" "ABI-10")
  )
--- End code ---

.....how can i add code to each one to change any selected dimension object to that chosen dimstyle?

For example, the user wants to change the current dim styles to say STD-5 (which is a 1:5 scale dimstyle) he or she types 5, (which the routine(s) above do), but if he /she has selected a dimension or a few of them, i want the program to not only switch the current dimstyle to that chosen one but it will also change the selected dims to that style too..

rkmcswain:
Here is one way:


--- Code: ---(defun C:5 ( / a) 
  (command "-dimstyle" "R" "ABI-5")
  (setq a (cdr (ssgetfirst)))
  (if a
    (command "._dimstyle" "_A" "_P" "")
  )
)

--- End code ---

hardwired:
Hi rkmcswain, thanks but that doesn't work for me - i tried selecting one dimension object and pressing 5 - the dimstyle didn't update, nor did the object change to that dimstyle, tried the same with multiple objects selected, same results..

And also noticed that if then press 5 without selecting anything (ie: to just update the current dimstyle), one of the dimension objects does change to the dimstyle (which is due to the 'previous' bit in the dimstyle part of the lisp) but this would change any dim object selected before, if it was only for changing the layer or editing the text..

rkmcswain:

--- Quote from: hardwired ---Hi rkmcswain, thanks but that doesn't work for me

--- End quote ---

You are right. I didn't even look at what I pasted in the window. Wrong bit of code....  :-o

Try this:


--- Code: ---(defun C:5 ( / a)
  (setq a (cadr (ssgetfirst)))
  (command "-dimstyle" "R" "ABI-5") 
  (if a (command "._dimstyle" "_A" a ""))
  (princ)
)

--- End code ---

Navigation

[0] Message Index

Go to full version