Jump to content

text selection - merge based on colour


Recommended Posts

I am not even sure how to pose this question - so here she goes:

I am not quite sure if you can select content with different colours within a text (see attachment). The code below only finds text colour selected by the layer.

Is there a way?

My whole intention is to sort them so that say if I pick BELL (colour 150) or RORGERS (colour 22) then the white text strings and colour 150 remains and the rest be removed - sorting by colour and merging the text condition the selection and colour!!!

 

Possible? 

(setq ss (ssget "X" '((0 . "*TEXT")(62 . 1))))

if yes...how???

text sample.dwg

Link to post
Share on other sites
34 minutes ago, Sambuddy said:

I am not even sure how to pose this question - so here she goes:

I am not quite sure if you can select content with different colours within a text (see attachment). The code below only finds text colour selected by the layer.

Is there a way?

My whole intention is to sort them so that say if I pick BELL (colour 150) or RORGERS (colour 22) then the white text strings and colour 150 remains and the rest be removed - sorting by colour and merging the text condition the selection and colour!!!

 

Possible? 


(setq ss (ssget "X" '((0 . "*TEXT")(62 . 1))))

if yes...how???

text sample.dwg 23.99 kB · 0 downloads

 

Difficult to say as I cannot open the drawing as it is in a later version than the one I use.

Link to post
Share on other sites

MText formatting is embedded within the text content (here is a reference for the majority of available formatting codes); as such, you will need to test the text content of the presence of the colour formatting code "\C<colour>;" where <colour> is the ACI colour number.

Link to post
Share on other sites
Quote

MText formatting is embedded within the text content (here is a reference for the majority of available formatting codes); as such, you will need to test the text content of the presence of the colour formatting code "\C<colour>;" where <colour> is the ACI colour number.

how do I implement that onto a code? a little more detail please

Link to post
Share on other sites
40 minutes ago, Sambuddy said:

how do I implement that onto a code? a little more detail please

  • Obtain a selection set of all MTEXT entities within the target space.
  • Iterate over the set (using one of the methods described here).
  • Obtain the full text content held by each MTEXT entity (concatenate all DXF group 3 & 1 values).
  • Use wcmatch to test for the existence of \C<colour>; within the content, where <colour> is the ACI colour number you require.
Link to post
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
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...