wimal Posted December 25, 2012 Share Posted December 25, 2012 How can I set the current dimension style by LISP:x Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 25, 2012 Share Posted December 25, 2012 (defun _SetDimStyleCurrent (dim / acdoc) (vl-load-com) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (tblsearch "DIMSTYLE" dim) (vla-put-activeDimstyle acdoc (vla-item (vla-get-Dimstyles acdoc) dim) ) ) (princ) ) Usage ... (_SetDimStyleCurrent "Standard") Quote Link to comment Share on other sites More sharing options...
wimal Posted December 26, 2012 Author Share Posted December 26, 2012 Thanks , the code is working nicely.And can you help me to go back to previous dim style without typing the style name. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 26, 2012 Share Posted December 26, 2012 Use the system variable to retrieve the current dimension style and after that implement my function to reset it back . (setq old-dim (getvar 'dimstyle)) (_SetDimStyleCurrent old-dim) Quote Link to comment Share on other sites More sharing options...
wimal Posted December 26, 2012 Author Share Posted December 26, 2012 OK THANKS (setq old-dim (getvar 'dimstyle)) (_SetDimStyleCurrent old-dim) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 26, 2012 Share Posted December 26, 2012 OK THANKS You're welcome . Quote Link to comment Share on other sites More sharing options...
samifox Posted May 4, 2016 Share Posted May 4, 2016 (vl-load-com) (defun c:test (/ dxf sym) (setq dxf (entget(setq sym (car(entsel))))) (cond ((= (cdr(assoc 0 dxf)) "DIMENSION") (and (_SetDimStyleCurrent (cdr(assoc 3 dxf)))[b][color="red"] (setvar "CLAYER" (cdr(assoc 3 dxf)))[/color][/b] )) (t nil) ) ) (defun _SetDimStyleCurrent (dim / acdoc) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (tblsearch "DIMSTYLE" dim) (vla-put-activeDimstyle acdoc (vla-item (vla-get-Dimstyles acdoc) dim) ) ) (princ) ) error: AutoCAD variable setting rejected: "CLAYER" "dim25 why? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 4, 2016 Share Posted May 4, 2016 (edited) Are you sure that you have a layer name with the same name of Dimension Style name ? If yes, this should work, otherwise layer name won't be set and no error reports should be received. (defun c:test (/ dxf sym sn) (if (and (setq sym (car (entsel "\nSelect dimension :"))) (= (cdr (assoc 0 (setq dxf (entget sym)))) "DIMENSION") (setq sn (cdr (assoc 3 dxf))) ) (progn (_SetDimStyleCurrent sn) (if (tblsearch "LAYER" sn) (setvar "CLAYER" sn) ) ) ) (princ) ) Edited May 5, 2016 by Tharwat Quote Link to comment Share on other sites More sharing options...
samifox Posted May 5, 2016 Share Posted May 5, 2016 Are you sure that you have a layer name with the same name of Dimension Style name ? If yes, this should work, otherwise layer name won't be set and no error reports should be received. (defun c:test (/ dxf sym sn) (if (and (setq sym (car (entsel "\nSelect dimension :"))) (= (cdr (assoc 0 (setq dxf (entget)))) "DIMENSION") (setq sn (cdr (assoc 3 dxf))) ) (progn (_SetDimStyleCurrent sn) (if (tblsearch "LAYER" sn) (setvar "CLAYER" sn) ) ) ) (princ) ) thanks (you forget entget nil) entity selection lanches a command with the same style and layer. command identity is the same of the select entity type ive managhed to write solution for dim and polyline 2 qestions 1. how can i retrive the last settings after completting the (command "command") 2.how can i clear the command line before applying the (command "command")? (vl-load-com) (defun c:test (/ dxf sym prlay prts prdim) (if(setq sym (car(entsel))) (progn (setq dxf (entget sym) prlay (getvar "CLAYER") prts (getvar "TEXTSTYLE") prdim (getCurrentDimstyle)) (setvar "CLAYER" (cdr(assoc 8 dxf))) (cond ((= (cdr(assoc 0 dxf)) "DIMENSION") (and (_SetDimStyleCurrent (cdr(assoc 3 dxf))) (command "_dimlinear"))) ((= (cdr(assoc 0 dxf)) "LWPOLYLINE") (command _pline)) (t nil) ) ) ) ) (defun _SetDimStyleCurrent (dim / acdoc) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (tblsearch "DIMSTYLE" dim) (vla-put-activeDimstyle acdoc (vla-item (vla-get-Dimstyles acdoc) dim) ) ) (princ) ) (defun getCurrentDimstyle (/ acdoc dim n) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)) dim (vla-get-activeDimstyle acdoc) n (vla-get-name dim)) n ) Quote Link to comment Share on other sites More sharing options...
Phani Posted January 11, 2019 Share Posted January 11, 2019 (command "dimstyle" "r" dim) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.