Author Topic: Dimstyle Applying..  (Read 1658 times)

0 Members and 1 Guest are viewing this topic.

hardwired

  • Guest
Dimstyle Applying..
« on: April 07, 2008, 04:45:20 AM »
Hi,

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


Code: [Select]
; 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")
  )

.....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

  • Swamp Rat
  • Posts: 978
Re: Dimstyle Applying..
« Reply #1 on: April 07, 2008, 08:33:27 AM »
Here is one way:

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

hardwired

  • Guest
Re: Dimstyle Applying..
« Reply #2 on: April 07, 2008, 09:37:18 AM »
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

  • Swamp Rat
  • Posts: 978
Re: Dimstyle Applying..
« Reply #3 on: April 07, 2008, 10:47:30 AM »
Quote from: hardwired
Hi rkmcswain, thanks but that doesn't work for me

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

Try this:

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