Jump to content
Ahankhah

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

Recommended Posts

Ahankhah

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?

Share this post


Link to post
Share on other sites
Lee Mac

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.

Share this post


Link to post
Share on other sites
Ahankhah

Lee, you are very swift :o, thank you very much for all your helps :lol:.

Share this post


Link to post
Share on other sites
Lee Mac

You're welcome Mehrdad, let me know how you get on :)

Share this post


Link to post
Share on other sites
Ahankhah
You're welcome Mehrdad, let me know how you get on :)

It works excellent. o:)

Share this post


Link to post
Share on other sites
Lee Mac
It works excellent. o:)

 

That's great. :)

Share this post


Link to post
Share on other sites
Ahankhah

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.

Share this post


Link to post
Share on other sites
Ahankhah

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

Share this post


Link to post
Share on other sites
Lee Mac
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 :)

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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