Anushka Posted May 29, 2019 Posted May 29, 2019 I have over 1000,000 texts in the layer "apartments" in a drawing. Is there a way to read the value of the text up to the letter "A" Insert the block in justification of the texts. and change the value of the attribute to the correct one. if the value is less than 6 -> Do not insert the block. 6 to 10 -> value of Atribute 1 11 to 18 -> value of Atribute 2 19 to 26 -> value of Atribute 3 27 to 34 -> value of Atribute 4 35 to 42 -> value of Atribute 5 43 to 50 -> value of Atribute 6 51 to 58 -> value of Atribute 7 59 to 66 -> value of Atribute 8 67 to 74 -> value of Atribute 9 75 to 82 -> value of Atribute 10 [...] I've attached an example of .dwg apart.dwg Quote
rlx Posted May 30, 2019 Posted May 30, 2019 (defun c:t1 ( / doc spc ss obj-ss txt-ins txt-str num blk-num bo) (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)) spc (vla-get-block (vla-get-activelayout doc))) (defun getip (o) (if (= (vla-get-alignment o) 0)(vla-get-InsertionPoint o)(vla-get-TextAlignmentPoint o))) (defun wai (blk tag val) (setq tag (strcase tag)) (if blk (vl-some '(lambda (x)(if (= tag (strcase (vla-get-tagstring x))) (progn (vla-put-textstring x val) val)))(vlax-invoke blk 'getattributes)))) (cond ((not (tblsearch "block" "highlighter")) (alert "Block 'highlighter' not found in drawing")) ((not (setq ss (ssget "X" '((0 . "TEXT"))))) (alert "No texts found to process")) (T (vlax-for txt-obj (setq obj-ss (vla-get-ActiveSelectionSet doc)) (setq txt-ins (getip txt-obj) txt-str (strcase (vla-get-textstring txt-obj))) (if (and (wcmatch txt-str "*#A*") (setq i (vl-string-position (ascii "A") txt-str)) (setq num (atoi (substr txt-str 1 i))) (> num 5) (setq blk-num (/ (+ num 5) 8)) (setq bo (vla-insertblock spc txt-ins "highlighter" 1 1 1 0))) (wai bo "QUANTIDADE" (itoa blk-num)))))) (if obj-ss (vl-catch-all-apply 'vlax-release-object (list obj-ss))) (vla-regen doc acActiveViewport) (princ) ) 1 Quote
ronjonp Posted May 30, 2019 Posted May 30, 2019 (edited) Two answers HERE too @rlx Like the (/ (+ num 5) 8) Much simpler than my solution ! Edited May 30, 2019 by ronjonp 1 Quote
rlx Posted May 30, 2019 Posted May 30, 2019 2 minutes ago, ronjonp said: Two answers HERE too ah, didn't know that ... was just taking a break from routine I am working on right now but was having a little writers block... better find other way of having a break thanx ronjonp Quote
ronjonp Posted May 30, 2019 Posted May 30, 2019 3 minutes ago, rlx said: ah, didn't know that ... was just taking a break from routine I am working on right now but was having a little writers block... better find other way of having a break thanx ronjonp Yeah I did the same. This cross posting gets old... Quote
Recommended Posts
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.