Jump to content

Change Block


ghostware

Recommended Posts

I want to change block color layer and ltype (1000 pst.)

 

Block entity 1:

Layer 1 to 0

Color bylayer to byblock

Ltype bylayer to byblock

 

Block entity 2:

Layer 1 to 0

Color 2 to 1

Ltype Dashdot (do not change)

 

Thanks for any help. :)

Pascal

change block.jpg

Link to comment
Share on other sites

I want to change block color layer and ltype (1000 pst.)

 

Block entity 1:

Layer 1 to 0

Color bylayer to byblock

Ltype bylayer to byblock

 

Block entity 2:

Layer 1 to 0

Color 2 to 1

Ltype Dashdot (do not change)

 

Thanks for any help. :)

Pascal

 

I havent't time to test just try yourself

 

(defun C:CBC  (/ blockobj bname en ent obj);change block 

 (setq ent (entsel "\nSelect block: "))
 (setq en (car ent)
obj (vlax-ename->vla-object en)
bname (vla-get-effectivename obj)
blockobj
     (vla-item (vla-get-blocks
		 (vla-get-activedocument
		   (vlax-get-acad-object)))
	       bname)
    )
 
 (vla-put-layer obj "0")
 
 (vlax-for item blockobj

     (if (eq "1" (vla-get-layer item))
     (if (and (eq "AcDbLine" (vla-get-objectname item))
       (eq "DASHDOT" (strcat (vla-get-linetype item)))
       (eq 2 (vla-get-color item))
       )
(progn
(vla-put-layer item "0")  
(vla-put-color item 1))
(progn
  (vla-put-layer item "0")
  (vla-put-color item acByBlock)
  (vla-put-linetype item "BYBLOCK")
)
)
)
)

 (vla-regen (vla-get-activedocument
       (vlax-get-acad-object))
     acallviewports)
 
 (princ)
 )
(princ "\n   ***  Type CBC to execute  ***")
(prin1)

(vl-load-com)

 

~'J'~

Link to comment
Share on other sites

Hi Fixo,

 

CBC.lsp works great,

 

Now I have the following problem.

 

I want to change 3 colors (see example).

 

Pascal :)

 

Pascal, post the sample drawing, please

 

I use A2008

 

Your pic is not clearly enough for me :(

 

~'J'~

Link to comment
Share on other sites

Here is my sample drawing..

 

Hi, Pascal

Try this again

 

(defun C:CB2  (/ blockobj bname en ent obj)	  ;change block 

 (setq ent (entsel "\nSelect block: "))
 (setq	en	 (car ent)
obj	 (vlax-ename->vla-object en)
bname	 (vla-get-effectivename obj)
blockobj
	 (vla-item (vla-get-blocks
		     (vla-get-activedocument
		       (vlax-get-acad-object)))
		   bname)
)

 (vla-put-layer obj "0")

 (vlax-for item  blockobj

   (if	(and (eq "DASHDOT" (strcase (vla-get-linetype item)))
     (eq 2 (vla-get-color item))
     )
     (vla-put-color item 1)
     )

   (if	(and (eq "ByLayer" (vla-get-linetype item))
     (eq acLnWtByLayer (vla-get-lineweight item))
     (eq 2 (vla-get-color item))
     )
     (vla-put-color item 
     )

   (if	(eq acByLayer (vla-get-color item))
     (vla-put-color item acByBlock)
     )

   (vla-put-layer item "0")

   )

 (vla-regen (vla-get-activedocument
       (vlax-get-acad-object))
     acallviewports)

 (princ)
 )
(princ "\n   ***  Type CB2 to execute  ***")
(prin1)

(vl-load-com)

 

~'J'~

Link to comment
Share on other sites

Thx Fixo! for your routine (CB2.LSP).

Now I could do my job faster than before.

 

Thank you very much for your time. :D

You're welcome

Cheers :)

 

~'J'~

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...