Help... Need a lisp that create new layer group filter for selected block

Help... Need a lisp that create new layer group filter for selected block

designdistrict7
Advocate Advocate
1,399 Views
13 Replies
Message 1 of 14

Help... Need a lisp that create new layer group filter for selected block

designdistrict7
Advocate
Advocate

Hello,
CAD/lisp experts , I need a help. can you write a lisp that can make selected block layer to a new layer group filter automatically. What I need if I select a block all layer used in that block will be add or create to a new layer group filter. So I can change layer color and properties easily from layer group filter without opening block editor.

0 Likes
Accepted solutions (2)
1,400 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here's my routine... already posted somewhere.

Message 3 of 14

devitg
Advisor
Advisor

@ВeekeeCZ Hi, the 

(initdia)

Is absent or lost  

0 Likes
Message 4 of 14

designdistrict7
Advocate
Advocate

Thanks man, I don't have the words to express my gratitude, thanks 👍, may be you have the lisp that can change the dimension text to bylayer, dimension color not on bylayer inside block, if you have please share.

Thank you.

0 Likes
Message 5 of 14

designdistrict7
Advocate
Advocate

Hi, I dont understand ?

0 Likes
Message 6 of 14

devitg
Advisor
Advisor

@designdistrict7 Sorry , I read initdia, and guess it was user defun. 

 

it is an AUTOLISP-ACAD command

 

initdia (AutoLISP)

Forces the display of the next command's dialog box

Supported Platforms: Windows and Mac OS

 

0 Likes
Message 7 of 14

ВeekeeCZ
Consultant
Consultant

@designdistrict7 wrote:

... may be you have the lisp that can change the dimension text to bylayer, dimension color not on bylayer inside block, if you have please share...


 

Better post a test file... 

0 Likes
Message 8 of 14

designdistrict7
Advocate
Advocate

Thanks

0 Likes
Message 9 of 14

designdistrict7
Advocate
Advocate

Hi,

Please see sample file, set by layer not changing leader and dimension text color , if you have lisp for this please share 

0 Likes
Message 10 of 14

ВeekeeCZ
Consultant
Consultant

Try this code. But... there is some issue with dim-color update if inside the block. You may still need to go inside the editor and run the routine from there. Still think it will speed up your job. 

BTW also can try one of THESE  solutions... thought don't think it will help with the issues.

 

(vl-load-com)

(defun c:FixDimColors (/ s i e d n f fx)
  
  (defun fx (n / be o)
    (if (not (member n f))
      (progn
	(setq f  (cons n f)
	      be (tblobjname "BLOCK" n)
	      )
	(while (setq be (entnext be))
	  (if (= (cdr (assoc 0 (entget be))) "INSERT")
	    (fx (cdr (assoc 2 (entget be)))))
	  (setq o (vlax-ename->vla-object be))
	  ;(vl-catch-all-apply 'vla-put-layer (list o "0"))
	  (vl-catch-all-apply 'vla-put-color (list o 256))
	  (vl-catch-all-apply 'vla-put-textcolor (list o 256))
	  (vl-catch-all-apply 'vla-put-extensionLineColor (list o 256))
	  (vl-catch-all-apply 'vla-put-dimensionlinecolor (list o 256))
	  ;(vl-catch-all-apply 'vla-put-linetype (list o "bylayer"))
	  ;(vl-catch-all-apply 'vla-put-lineweight (list o -1))
	  ;(vl-catch-all-apply 'vla-put-plotstylee (list o "bylayer"))
	  ))))
  
  (if (and (setq s (ssget)) ;(list (cons 0 "INSERT"))))
	   (not (vla-startundomark (vla-get-activedocument (vlax-get-acad-object))))
	   )
    (repeat (setq i (sslength s))
      (setq i (1- i)
	    e (ssname s i)
	    d (entget e)
	    f nil
	    o (vlax-ename->vla-object e))
      (vl-catch-all-apply 'vla-put-color (list o 256))
      (vl-catch-all-apply 'vla-put-textcolor (list o 256))
      (vl-catch-all-apply 'vla-put-extensionLineColor (list o 256))
      (vl-catch-all-apply 'vla-put-dimensionlinecolor (list o 256))
      (if (= "INSERT" (cdr (assoc 0 d)))
	(fx (cdr (assoc 2 d))))))
  (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  (vl-cmdf "_.regen")
  (princ)
  )

 

0 Likes
Message 11 of 14

designdistrict7
Advocate
Advocate

Hi, I found one, but this one have no option to choose block, once it run entire drawing will change to bylayer , can you edit and add one option to select block or object.

 

(defun c:All2BYLA nil
(vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for obj block
(if (wcmatch (vla-get-objectname obj) "AcDb*Dimension,AcDb*Leader,AcDb*MLeader")
(foreach prop '(Color DimensionLineColor ExtensionLineColor LeaderLineColor LeaderColor TextColor)
(vl-catch-all-apply 'vlax-put-property (list obj prop acbylayer))
)
(vl-catch-all-apply 'vla-put-color (list obj acbylayer))
)
)
)
(princ)
)
(vl-load-com) (princ)

Message 12 of 14

designdistrict7
Advocate
Advocate

Thanks man, thanks for your time and sorry for asking again more helps

0 Likes
Message 13 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this one, it should make it.

0 Likes
Message 14 of 14

designdistrict7
Advocate
Advocate

Nice... that is awesome.  Thanks man

0 Likes