change dimension styles, code error

change dimension styles, code error

Anonymous
Not applicable
1,078 Views
3 Replies
Message 1 of 4

change dimension styles, code error

Anonymous
Not applicable

Hello,

the code I made is to creat a new dimension style if not exist, then change all existing dimension to this new style. Not sure which part has problem and don`t know how Vlide works.

; dimension style and texts to be ARIAL
(defun c:adim ()

  ;CHECK IF "NEUF-ARIAL-ANNO" EXIT
  (setq new_dim "NEUF-ARIAL-ANNO")
  
  (if (tblsearch "DImstyle" new_dim )
	(command "_dimstyle" "_R" new_dim)
	(command "_.dim" "_DIMADEC" "0";; Angular decimal places
			"_DIMALT" "Off";; Alternate units selected
			"_save" new_dim ;; to save  dimstyle and become current
			"_exit");; to exit the command
	);; if

  (if (setq ss (ssget "_X" (0 . "DIMENSION")))

  (setq n 0)

  (repeat (sslength ss)
    (setq en (ssname ss n))
    (setq endata (entget en))
    (setq entype (cdr (assoc 3 endata)))
    (if (not (= entype "ARIAL"))
      (sub_dim_style)
      );if
    (setq n (1+ n))
    ); end repeat
  (prin1)
	); if
    ); defun

  (defun sub_dim_style()
  (setq old_3_list (assoc 3 endata))
    (setq new_3_list (cons 3 new_dim))
    (setq endata (subst new_3_list old_3_list endata))
    (entmod endata)
      )

  (prompt "change dimension style")
  (prin1)
  
  
0 Likes
Accepted solutions (1)
1,079 Views
3 Replies
Replies (3)
Message 2 of 4

Ranjit_Singh
Advisor
Advisor
Accepted solution

something like this maybe

(defun c:adim  (/ en endata entype n new_dim ss)
 (setq new_dim "NEUF-ARIAL-ANNO")
 (if (tblsearch "DImstyle" new_dim)
  (command "_dimstyle" "_R" new_dim)
  (command "_.dim" "_DIMADEC" "0" "_DIMALT" "Off" "_save" new_dim "_exit"))
 (if (setq ss (ssget "_X" '((0 . "DIMENSION"))))
  (progn (setq n 0)
         (repeat (sslength ss)
          (setq en (ssname ss n))
          (setq endata (entget en))
          (setq entype (cdr (assoc 3 endata)))
          (if (not (= entype "ARIAL"))
           (entmod (subst (cons 3 new_dim) (assoc 3 endata) endata)))
          (setq n (1+ n)))))
 (princ))
Message 3 of 4

pbejse
Mentor
Mentor

@Anonymous wrote:

...Not sure which part has problem and don`t know how Vlide works.


Start reading hifrank001

 

The Visual LISP Editor - Part 1

The Visual LISP Editor - Part 2

 

 

 

HTH

Message 4 of 4

Anonymous
Not applicable

so cool! I'll reat them.

thanks, pBe.

0 Likes