Jump to content

Adding Annotation Scales to an object via Dictadd


cwake

Recommended Posts

Every time I need to add annotation scales to entities in LISP I have been limited to the capabilities of (vl-cmdf "_.-objectscale" sset "" "add" scale "").

 

For a long time I have wanted to be able to add scales via the extension dictionary, but I've never had success. The dictionary records are created ok, but the entity doesn't seem to inherit the scales and it disappears.

 

This is me playing with my routine that changes TEXT to MTEXT. I collect the scales used by the original TEXT entity, then after creating the MTEXT entity, I try to add the same scales to the MTEXT entity via the dictionary.

 

Can anyone explain why it fails? I can post the whole function if needed.

 

(defun addannscale (ent scales / acdbdict dict elist scdict txtocd scale)
   (entmod (setq elist (append (entget ent) '((-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}")))))));annotative
   (setq dict (vlax-vla-object->ename (vla-getextensiondictionary (vlax-ename->vla-object ent)));this will get or if not present create the entity extension dictionary
         acdbdict (dictadd dict "AcDbContextDataManager"
                           (entmakex (list '(0 . "DICTIONARY")
                                           '(100 . "AcDbDictionary")
                                           '(280 . 0)
                                           '(281 . 1)
                                           )
                                     )
                           )
         scdict (dictadd acdbdict "ACDB_ANNOTATIONSCALES"
                         (entmakex
                           (list '(0 . "DICTIONARY")
                                 '(100 . "AcDbDictionary")
                                 '(280 . 0)
                                 '(281 . 1)
                                 )
                           )
                         )
         )
   (foreach x scales
     (setq txtocd (entget (cdr x))
           scale (entget (cdr (assoc 340 txtocd)))
           )
     (dictadd scdict
              (car x)
              (entmakex (list '(0 . "ACDB_MTEXTOBJECTCONTEXTDATA_CLASS")
                              '(100 . "AcDbObjectContextData")
                              (assoc 70 txtocd)
                              (assoc 290 txtocd)
                              '(100 . "AcDbAnnotScaleObjectContextData")
                              (assoc 340 txtocd) ;The scale ename in the dictionary
                              (cons 70 (cdr (assoc 71 elist)));this is the attachment point at the time the entity was created
                              (cons 10 (cdr (assoc 11 elist)));direction vector
                              (cons 11 (cdr (assoc 10 elist)));insert point
                              '(40 . 0)
                              '(41 . 0)
                              (cons 42 (/ (* (cdr (assoc 42 elist)) (cdr (assoc 141 scale))) (cdr (assoc 140 scale))))
                              (cons 43 (/ (* (cdr (assoc 43 elist)) (cdr (assoc 141 scale))) (cdr (assoc 140 scale))))
                              '(71 . 0)
                              )
                        )
              )
     );foreach
   )

 

The scales are passed to the function in the format retrieved using:

 

(defun entscales (en / a b)
   (if (and (setq a (cdr (assoc 360 (entget en))))
            (setq a (dictsearch a "AcDbContextDataManager"))
            (setq a (dictsearch (cdr (assoc -1 a)) "ACDB_ANNOTATIONSCALES"))
            )
     (while (assoc 3 a)
       (setq b (cons (cons (cdr (assoc 3 a)) (cdr (assoc 350 a))) b)
             a (cddr (member (assoc 3 a) a))
             )
       )
     )
   (reverse b)
   )

Link to comment
Share on other sites

  • 2 months later...

I've had issues with this for quite a while. To the point where I simply stopped trying. E.g. my first head-butting with annoscales and dictionaries was in 2008:

 

 

If you can't get it working properly through the command calls, then I'd suggest going the DotNet route. Even adding some lisp-callable functions. Perhaps ask the question in this forum: http://forums.augi.com/forumdisplay.php?1417-Bridging-the-Gap-LISP-NET-LISP

It was specifically set up to discuss making stuff available to lisp from within DotNet.

Link to comment
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
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...