Jump to content

Text - Annotative - Properties > "Yes"


Recommended Posts

Posted (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 by abra-CAD-abra
Posted (edited)

There are three issues:

  1. For *TEXT objects that were never annotative the Xdata is missing. So only relying on subst will not work.
  2. If you want to retrieve Xdata you should specify the application when you use entget: (entget x '("AcadAnnotative"))
  3. 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 by Roy_043
Posted (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 by abra-CAD-abra
Posted (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 by BIGAL
Posted

Thank you, BIGAL.

 

I will investigate the VL method.

 

Much appreciated 👍

Posted (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 by Roy_043
Posted

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)

 

 

Posted

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..

Posted

The code in @BIGAL's last post will entmod the modelspace or paperspace block. I don't see how that is useful here.

 

Posted (edited)

@tombu The code you refer to deals with Xdata. An extension dictionary is something else.

Edited by Roy_043
Posted (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 by Roy_043
Posted

@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" "")
)

 

Posted

Lee Mac, Roy - Thank you for your time and assistance.

 

I will take a look and I will return 👍

 

Many thanks..

  • 1 month later...
Posted

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..

Posted

So there is an 'Annotative' property, I did not know that. Is there a vla-put-annotative function as well?

Posted
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)

Posted

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).

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...