Put dimension objects on layers according to dimention style name

Put dimension objects on layers according to dimention style name

GeryKnee
Advocate Advocate
938 Views
5 Replies
Message 1 of 6

Put dimension objects on layers according to dimention style name

GeryKnee
Advocate
Advocate

Hello,

How could be a lisp command that after call (Undo Start here)

1) Looks inside mode space for all the dimension object

2) Fo every dim object  objI

    Let the obj.style DsJ named be "NDSJ"

    If there isn't a layer named "Dim_NDSJ" creates a new layer named "Dim_NDSJ" with layer.Color

    the    DsJ.TextColor   

    If theres a layer named "Dim_NDSJ" changes the layer.Color to DsJ.TextColor

3) After all Halts and Undo Ends

 

Thans,

Gery

 

 

    

0 Likes
Accepted solutions (1)
939 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant

Here is something to start with. It dose not all you want, but I guess you're skilled enough to figure it out by yourself.

 

(vl-load-com)

(defun c:DimSortByStyle ( / ss ent stl lay)

  (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
  
  (if (setq ss (ssget "_X" '((0 . "DIMENSION") (410 . "Model"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (setq stl (getpropertyvalue (getpropertyvalue ent "DimensionStyle") "Name"))
      (setq lay (strcat "Dim_" stl))
      (if (or (tblsearch "LAYER" lay)
              (vl-cmdf "_.-LAYER" "_N" lay "" "")
              )
        (setpropertyvalue ent "LayerId" (tblobjname "LAYER" lay)))))
  
  (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  (princ)
)

 

Message 3 of 6

GeryKnee
Advocate
Advocate
Accepted solution

Sorry,

getpropertyvalue isn't recognized from my old Autocad 2006 version.
Do you have solution about it?

utocad text window:

Command: DimSortByStyle
; error: no function definition: GETPROPERTYVALUE
Command:
Thanks for your time
Gery.

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant

Sure. Plain AutoLisp.

(vl-load-com)

(defun c:DimSortByStyle ( / ss ent stl lay)

  (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
  
  (if (setq ss (ssget "_X" '((0 . "DIMENSION") (410 . "Model"))))
    (repeat (setq i (sslength ss))
      (setq ent (entget (ssname ss (setq i (1- i)))))
      (setq stl (cdr (assoc 3 ent)))
      (setq lay (strcat "Dim_" stl))
      (if (or (tblsearch "LAYER" lay)
              (vl-cmdf "_.-LAYER" "_N" lay "")
              )
        (entmod (subst (cons 8 lay) (assoc 8 ent) ent)))))
  
  (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  (princ)
)
0 Likes
Message 5 of 6

GeryKnee
Advocate
Advocate

Yes,

That's perfect.

Thank you very match for your time.

Gery

0 Likes
Message 6 of 6

ВeekeeCZ
Consultant
Consultant

Just for your info since you quite new around here. By marking solution you give the info to other potential users searching for similar issue, that your issue was solved AND by this or that post to get quick overlook over the topic conversation. So don't mark your msg where you're saying "its not working."

0 Likes