PDA

View Full Version : Changes all the text color selected area (text, mtext, attdef, blk def.) skip lines and xref



Remco Koedoot
2022-08-25, 09:26 AM
-------------------------------------------------------

Opie
2022-08-25, 12:58 PM
I'm not understanding your post. Are you wanting to select a specific area of the drawing, which may change each time this is executed, to change the color of all text or attributes to ACI color 2? What should happen if a block is inserted into the drawing in multiple places with at least one of those places being within the specific area?

Setting the attributes and text objects within a block to ByBlock for the color may ease some of your pain. You could then change the layer or block object color without additional code.

Tom Beauford
2022-09-01, 11:47 AM
Yes to be able to select a specific area of the drawing, window of crossing, which is executed each time. Changing the color of text, mtext attdef etc. can be changed.
Change the color of any text or attributes to ACI color. The selected blocks must be redefined, i.e. renamed and modified. for example blockname1 in blockname1(1)
If block blockname1 is not in the selection, it should not be modified and should be renamed.
I can manually adjust it in a drawing, but routines are there to make the work more pleasant.

Must be a combination of:

CopyRenameBlockV1-5.lsp (copy and rename a block)
atcolor.lsp (change the attributes of block to a selected color code)
update-block-color.lsp (Change all entites, the wish is only text elements)
change-text-objects-to-color-2-yellow.lsp (select area and change the text color to 2)

Opie pointed out that changing the definition of a block affects every insertion of that block in the drawing which is why he suggested setting the attributes and text objects within a block to ByBlock for the color so you could then change the layer or block object color without additional code. You need to understand and explain how you want only the selected blocks to be modified.

If you want us to combine lisps for you why didn't you provide links to where they could be found?
Otherwise the list is useless.

peter
2022-09-02, 02:46 AM
OK I took a step back and rather than try to debug your program I took the liberty to re-code it in my style.

In my code I use a recursive function to drill down into blocks inside blocks etc... to get all of the selected objects.

It creates a list of objects inside and attributes.

Be aware if you have other instances of selected blocks... they will also change.

Anyways...

The act of changing color or any other property is relatively simple once you have the list of objects.

Regards P-



;___________________________________________________________________________________________________________|
;
; Written By: Peter Jamtgaard copyright 2022 All Rights Reserved
;___________________________________________________________________________________________________________|

;___________________________________________________________________________________________________________|
;
; Comand line function list
;___________________________________________________________________________________________________________|

;* C:NestedObjects
;* Command line function to get a list of objects and nested objects from selection set

;___________________________________________________________________________________________________________|
;
; General Function Header List
;___________________________________________________________________________________________________________|

; Function List Argument1 Argument2 Arguement3

;* (AttributeObjectAdd objBlock)
;* Function to add an attribute object to a list of objects

;* (NestedObjects objSelection)
;* (Recursive) Function to get all nested and attribute objects from another object

;* (ObjectAdd objItem)
;* Function to add an object to a list of objects

;$ End Header

;___________________________________________________________________________________________________________|
;
; Command line function to get a list of objects and nested objects from selection set
;___________________________________________________________________________________________________________|

(defun C:NestedObjects (/ entSelection intCount lstObjects objSelection ssSelections)
(if (and (princ "\nSelect Objects: ")
(setq ssSelections (ssget))
)
(repeat (setq intCount (sslength ssSelections))
(setq intCount (1- intCount))
(setq entSelection (ssname ssSelections intCount))
(setq objSelection (vlax-ename->vla-object entSelection))
(nestedobjects objSelection)
)
)
(mapcar '(lambda (X)(vla-put-color X 1)) lstObjects)
(reverse lstObjects)
)

;___________________________________________________________________________________________________________|
;
; Function to add an attribute object to a list of objects
;___________________________________________________________________________________________________________|

(defun AttributeObjectAdd (objBlock / objAttribute)
(if (= (vla-get-hasattributes objBlock) :vlax-true)
(foreach objAttribute (vlax-invoke objBlock "getattributes")
(objectadd objAttribute)
)
)
)

;___________________________________________________________________________________________________________|
;
; (Recursive) Function to get all nested and attribute objects from another object
;___________________________________________________________________________________________________________|

(defun NestedObjects (objSelection / colBlockReference objBlock strBlockName)
(objectadd objSelection)
(if (wcmatch (vla-get-objectname objSelection) "AcDbBlockReference,AcDbMInsertBlock")
(progn

(AttributeObjectAdd objSelection)

(vlax-for objBlock (vla-item
(vla-get-blocks
(vla-get-document objSelection)
)
(vla-get-name objSelection)
)
(NestedObjects objBlock)
)
)
)
)

;___________________________________________________________________________________________________________|
;
; Function to add an object to a list of objects
;___________________________________________________________________________________________________________|

(defun ObjectAdd (objItem / strHandle)
(if (not (member objItem lstObjects))
(setq lstObjects (cons objItem lstObjects))
)
)

(princ "!")
(vl-load-com)

Tom Beauford
2022-09-21, 11:31 AM
You need to edit your posts and use code tags instead of expecting an administrator to fix all of your posts.
Click the [Go Advanced] button in the bottom right to get the full Toolbars.
Click the # button and place your code inside.
You can attach files as well but for code you've downloaded providing a link to where you downloaded it provides the best background as to what the lisp is supposed to do and who wrote the code and would be able to best answer questions about it like http://www.lee-mac.com/copyblock.html.

See also: https://www.cadtutor.net/forum/topic/76050-changes-all-the-color-of-text-in-selected-blocks-definitions-to-color-2/