Jump to content

call tblobjname on a drawing opened as ObjecDBX! Is it possible???????


Ahankhah

Recommended Posts

Hi all,

the following code shows whether a text style is annotative (written by Lee):

 

(defun LM:isAnnotative (style / object annotx)
(and
 (setq object (tblobjname "STYLE" style))
 (setq annotx (cadr (assoc -3 (entget object '("AcadAnnotative")))))
 (= 1 (cdr (assoc 1070 (reverse annotx))))
)
)

 

Is it possible to call tblobjname on a drawing which is opened as a ObjectDBX?

Link to comment
Share on other sites

No, tblobjname is not available through an ObjectDBX interface.

 

Here is a Visual LISP alternative:

 

;; Annotative-p  -  Lee Mac
;; Predicate function to determine whether a textstyle
;; is annotative.
;;
;; Written in Visual LISP for compatibility with ObjectDBX

(defun LM:Annotative-p ( doc style )
   (and
       (null
           (vl-catch-all-error-p
               (setq style
                   (vl-catch-all-apply 'vla-item
                       (list (vla-get-textstyles doc) style)
                   )
               )
           )
       )
       (
           (lambda ( getvalue / xtype xvalue )
               (vla-getxdata style "AcadAnnotative" 'xtype 'xvalue)
               (
                   (lambda ( elist )
                       (= 1 (cdr (assoc 1070 (reverse elist))))
                   )
                   (apply 'mapcar (cons 'cons (mapcar 'getvalue (list xtype xvalue))))
               )
           )
           (lambda ( data )
               (cond
                   (   (eq 'variant (type data))
                       (getvalue (vlax-variant-value data))
                   )
                   (   (eq 'safearray (type data))
                       (mapcar 'getvalue (vlax-safearray->list data))
                   )
                   (   data   )
               )
           )
       )
   )
)

 

Pass it the ObjectDBX Document Object and Style name.

Link to comment
Share on other sites

Lee,

would you explain some about getvalue in your code?

No, tblobjname is not available through an ObjectDBX interface.

 

Here is a Visual LISP alternative:

 

;; Annotative-p - Lee Mac
;; Predicate function to determine whether a textstyle
;; is annotative.
;;
;; Written in Visual LISP for compatibility with ObjectDBX

(defun LM:Annotative-p ( doc style )
(and
(null
(vl-catch-all-error-p
(setq style
(vl-catch-all-apply 'vla-item
(list (vla-get-textstyles doc) style)
)
)
)
)
(
(lambda ( [b]getvalue[/b] / xtype xvalue )
(vla-getxdata style "AcadAnnotative" 'xtype 'xvalue)
(
(lambda ( elist )
(= 1 (cdr (assoc 1070 (reverse elist))))
)
(apply 'mapcar (cons 'cons (mapcar '[b]getvalue[/b] (list xtype xvalue))))
)
)
(lambda ( data )
(cond
( (eq 'variant (type data))
([b]getvalue[/b] (vlax-variant-value data))
)
( (eq 'safearray (type data))
(mapcar '[b]getvalue[/b] (vlax-safearray->list data))
)
( data )
)
)
)
)
)

 

Pass it the ObjectDBX Document Object and Style name.

Link to comment
Share on other sites

I think I found out the answer: You use second lambda as argument of the first lambda and in the second, you use itself (recursively).

 

You've got it. Its probably more obfuscated / complicated than it needs to be, since I could have instead defined a recursive subfunction called 'getvalue' and called it from within the 'LM:Annotative-p' function to evaluate the variants returned by the getxdata method; but that would be too obvious :)

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