mission: select text of specific heights [ 0< x <1 ] - long numbers problem

mission: select text of specific heights [ 0< x <1 ] - long numbers problem

kyleVBU3E
Explorer Explorer
911 Views
2 Replies
Message 1 of 3

mission: select text of specific heights [ 0< x <1 ] - long numbers problem

kyleVBU3E
Explorer
Explorer

Sorry if this is a repeat, but i couldn't find anything similar in searches.

My current mission is to create some subroutines to translate text elements from an imperial drawing to a metric drawing - our operation uses two sets of templates, which causes quite a bit of mismatch at times and the process is currently quite laborious to convert between the two.

Currently, i have the function working for "rounded" numbers, anything to the precision of 3 digits is working correctly, as it is able to match strings and select the appropriate texts.
Where this breaks down, is when i have some "computed" entities (i.e. objects which have been taken from an imperial scale in an imperial template, and dropped into a metric template with metric scales - and thus the model text height is some weird value).

I've noticed that the height value in the extended data results in an extended 6 digit number, but i'm still unable to filter these text entities with this longer value if i hand-code them in - i suspect i'm not actually seeing the whole value that autocad associates with the entity.

I've also noticed that i can qselect all the text in question using the text heights as displayed in the properties window (which adheres to the drawing settings)

Can anyone shed some light on this? it seems to me there must be a way to make this work if it exists in qselect - i suspect i'm not handling a number correctly or trying to use the wrong value or something.




(defun c:ctxh ( / ff1 xx1 EntityData Data newheight oldheight annoscale oldheightin newheightin)

  
(setq annoscale (getvar "cannoscalevalue"))

  
(setq oldheightin  (/ (getreal "\n enter old text height: ") annoscale ))
(setq newheightin  (/ (getreal "\n enter new text height: ") annoscale ))

(setq oldheight (atof(rtos oldheightin  2 3)))
(setq newheight (atof(rtos newheightin  2 3)))

(setq selectionset (ssget "_X" (list '(0 . "TEXT,MTEXT") (cons 40 oldheight))))

(repeat (setq N (sslength selectionset))

(setq Data (ssname selectionset (setq N (- N 1))))
(setq EntityData (entget Data))
(setq ff1(assoc 40  EntityData))
(setq xx1 (cons 40  newheight))
(entmod(subst xx1 ff1 EntityData))
)
(princ)
)



0 Likes
Accepted solutions (1)
912 Views
2 Replies
Replies (2)
Message 2 of 3

scot-65
Advisor
Advisor
>> (ssget "_X" (list '(0 . "TEXT,MTEXT") (cons 40 oldheight)))

I believe you need to look at a Nested Boolean Expression for this line and
get a range /fuzz for the value.

It's been a long time since I did this - I'll use an example instead:

(setq a (ssget "x" '(
(-4 . "<and")
(0 . "INSERT") (8 . "*TEXT") (-4 . "<") (41 . 0.0)
(-4 . "and>"))) );setq

The above looks for blocks (containing text) that have been flipped on all text layers.

Reference (AutoCAD R2009):
Using the AutoLISP Language > Using AutoLISP to Manipulate AutoCAD Objects > Selection Set Handling > Selection Set Filter Lists >
Logical Grouping of Filter Tests

or
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-5CB54129-22A1-42B9-B97C-2D2F5597F90E

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 3 of 3

kyleVBU3E
Explorer
Explorer
Accepted solution

Thanks for getting back to me Scot, your solution is pretty good! Turns out i wasn't entirely correct about the problem though.
What i hadn't noticed was that it was only  mtext that was not being selected, because i was not properly retrieving the height value for mtext. when using property names, it turns out they don't use the same nomeclature 

 

in short for anyone who stumbles on this later, my rounding function worked correctly in lieu of fuzzy logic (its only text anyways and can be slightly wrong) and the following was how i correctly retrieved the height parameters (sorry mac users, i went the vlisp route)

 

;obName refers to text entity from selection set
;this first one is for text height (setq obHeight (vlax-get-property (vlax-ename->vla-object obName) 'height)) ;this second one is for mtext height (setq obHeight (vlax-get-property (vlax-ename->vla-object obName) "height"))
0 Likes