abra-CAD-abra Posted February 6, 2020 Posted February 6, 2020 (edited) All, Text - Annotative - Properties > "Yes" I try to ask as little as possible but I have hit a brick wall with this one. The following code is intended to switch the "Annotative" property for each *text entity to "Yes". This should, as I understand it, change this: (-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 0) (1002 . "}"))) to: (-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}"))) Code: (defun c:testx ( / s i x ent ) (if (setq s (ssget "_:L" '((0 . "*TEXT")))) (repeat (setq i (sslength s)) (setq x (ssname s (setq i (1- i)))) (setq ent (entget x)) (setq ent (subst (list -3 (list "AcadAnnotative" '(1000 . "AnnotativeData") '(1002 . "{") '(1070 . 1) '(1070 . 1) '(1002 . "}") ) ) (assoc -3 ent) ent ) ) (entmod ent) ) ) (princ) ) Any assistance would be greatly appreciated. Thank you in advance Edited February 6, 2020 by abra-CAD-abra Quote
Roy_043 Posted February 6, 2020 Posted February 6, 2020 (edited) There are three issues: For *TEXT objects that were never annotative the Xdata is missing. So only relying on subst will not work. If you want to retrieve Xdata you should specify the application when you use entget: (entget x '("AcadAnnotative")) An annotative *TEXT object also has an extension dictionary. Things get a little complex here and I am out of my depth. Maybe somebody else has already dug deeper? Edited February 6, 2020 by Roy_043 Quote
abra-CAD-abra Posted February 6, 2020 Author Posted February 6, 2020 (edited) Thanks for your input, Roy. I have taken your comments into consideration and tried a slightly different approach: (defun c:testx ( / s i x ent lst int ) (if (setq s (ssget "_:L" '((0 . "*TEXT")))) (repeat (setq i (sslength s)) (setq x (ssname s (setq i (1- i)))) (setq ent (entget x '("AcadAnnotative")) lst (assoc -3 ent) int (nth 4 (cadr lst)) ) (if (= (cdr int) 0) (progn (subst (cons 1070 1) int lst) (entmod ent)) ) ) ) (princ) ) Whilst it doesn't present any errors, it is still not working. I think I am getting close though... Edited February 6, 2020 by abra-CAD-abra Quote
BIGAL Posted February 7, 2020 Posted February 7, 2020 (edited) Thought I had an answer (vla-get-HasExtensionDictionary Obj) problem is if the object say using properties is changed to annotative returns true, turn off annotation it will still return true the extensiondict obviously just gets reset but not deleted. For anyone (if (= (vla-get-HasExtensionDictionary Obj) :vlax-true) (setq ED1 (vla-GetExtensionDictionary Obj)) a start. Maybe going in wrong direction with ED1. If its non annotative lst (assoc -3 ent) returns nil as no -3 so do if at that point. maybe do a foreach checking 1070 in list as there are 2. Edited February 7, 2020 by BIGAL Quote
abra-CAD-abra Posted February 7, 2020 Author Posted February 7, 2020 Thank you, BIGAL. I will investigate the VL method. Much appreciated Quote
Roy_043 Posted February 7, 2020 Posted February 7, 2020 (edited) Maybe I should have explained better. It is not just the presence of the extension dictionary that is important. You also have to look at (created and/or modify) the data structure in the dictionary. The dictionary contains references to the anno scales that apply to the object. Edited February 7, 2020 by Roy_043 Quote
BIGAL Posted February 8, 2020 Posted February 8, 2020 Try this inspiration from lee-mac : Original code by Lee-mac. (defun annotativetxt ( / txt ) (setq txt (car (entsel "pick text"))) (regapp "AcadAnnotative") (entmod (append (entget (cdr (assoc 330 (entget txt)))) '((-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}") ) ) ) ) ) ) (annotativetxt) Quote
abra-CAD-abra Posted February 8, 2020 Author Posted February 8, 2020 Thanks guys. Roy, I will invest some time to study this. BIGAL, I will try your code when I get into the office on Monday. Cheers.. Quote
Roy_043 Posted February 8, 2020 Posted February 8, 2020 The code in @BIGAL's last post will entmod the modelspace or paperspace block. I don't see how that is useful here. Quote
tombu Posted February 8, 2020 Posted February 8, 2020 There's a routine I use here for toggling text mask on dimensions http://forums.augi.com/showthread.php?161030-Remove-Text-Mask-On-Select-Dimension-Objetcs#2 It modifies the extension dictionary for dimensions just like you're trying to do with text and could easily be modified to work with text instead. Quote
Roy_043 Posted February 8, 2020 Posted February 8, 2020 (edited) @tombu The code you refer to deals with Xdata. An extension dictionary is something else. Edited February 8, 2020 by Roy_043 Quote
Roy_043 Posted February 8, 2020 Posted February 8, 2020 (edited) It is a bit complex: ANNOTATIVE TEXT: DICTIONARY DATA STRUCTURE Extension dictionary (attached to the text object) "AcDbContextDataManager" dictionary "ACDB_ANNOTATIONSCALES" dictionary "ACDB_TEXTOBJECTCONTEXTDATA_CLASS" entities (one for each anno scale). See entity list 1. Namedobjdict dictionary (attached to the dwg) "ACAD_SCALELIST" dictionary "SCALE" entities (one for each scale). See entity list 2. Entity list 1: ( (-1 . <Entity name: 29be0da0>) (0 . "ACDB_TEXTOBJECTCONTEXTDATA_CLASS") (5 . "85") (102 . "{ACAD_REACTORS") (330 . <Entity name: 29be08a0>) (102 . "}") (330 . <Entity name: 29be08a0>) (100 . "AcDbObjectContextData") (70 . 4) (290 . 1) (100 . "AcDbAnnotScaleObjectContextData") (340 . <Entity name: 2a1ed1e0>) ; Ename of "SCALE". (70 . 0) (50 . 0.0) (10 274.124929993263 101.04892773503 0.0) (11 0.0 0.0 0.0) ) Entity list 2: ( (-1 . <Entity name: 2a1ed1e0>) (0 . "SCALE") (5 . "49") (102 . "{ACAD_REACTORS") (330 . <Entity name: 2a1ed8e0>) (102 . "}") (330 . <Entity name: 2a1ed8e0>) (100 . "AcDbScale") (70 . 0) (300 . "1:1") (140 . 1.0) (141 . 1.0) (290 . 1) ) Edited February 8, 2020 by Roy_043 Quote
Roy_043 Posted February 8, 2020 Posted February 8, 2020 (edited) Here is a link that may be of interest: https://www.theswamp.org/index.php?topic=23613.0 Edited February 8, 2020 by Roy_043 Quote
Lee Mac Posted February 8, 2020 Posted February 8, 2020 You may also find this thread of interest. Quote
Roy_043 Posted February 9, 2020 Posted February 9, 2020 @Lee Mac: Thanks for that link. In BricsCAD V18 the _ObjectScale command will add the extension dictionary data to a non-annotative text entity, but not the required Xdata, which is a bit bizarre. But adding the Xdata is the easy part of the required operation. This proof-of-concept code works in BricsCAD V18: (defun c:MakeTxtAnno ( / enm) (regapp "AcadAnnotative") (setq enm (car (entsel))) (entmod (list (cons -1 enm) -3 '( "AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}") ) ) ) (command "_-objectscale" enm "" "_add" "1:1" "1:5" "") ) Quote
abra-CAD-abra Posted February 10, 2020 Author Posted February 10, 2020 Lee Mac, Roy - Thank you for your time and assistance. I will take a look and I will return Many thanks.. Quote
abra-CAD-abra Posted March 19, 2020 Author Posted March 19, 2020 Invariably, there's more than one way to skin the proverbial cat: (defun text2anno (/ s a i) (if (and (setq s (ssget "_X" '((0 . "*TEXT")))) (setq a 1) ) (repeat (setq i (sslength s)) (setpropertyvalue (ssname s (setq i (1- i))) "Annotative" a ) ) ) (princ) ) Still, if anybody can come up with a vanilla solution, I would be interested to study it. Cheers.. Quote
Roy_043 Posted March 19, 2020 Posted March 19, 2020 So there is an 'Annotative' property, I did not know that. Is there a vla-put-annotative function as well? Quote
abra-CAD-abra Posted March 20, 2020 Author Posted March 20, 2020 16 hours ago, Roy_043 said: So there is an 'Annotative' property, I did not know that. Is there a vla-put-annotative function as well? Using the "LSP" command (C3D 2018), the following functions are listed, however, I cannot find any documentation on these functions. VLA-GET-ANNOTATIVE (SUBR) VLA-PUT-ANNOTATIVE (SUBR) Quote
Roy_043 Posted March 20, 2020 Posted March 20, 2020 Right, these functions also exist in BricsCAD. But they only work for Mleader styles. The annotative property of other objects is not exposed. The setpropertyvalue function is missing in BricsCAD (V18). 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.