Ahankhah Posted February 20, 2012 Posted February 20, 2012 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? Quote
Lee Mac Posted February 20, 2012 Posted February 20, 2012 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. Quote
Ahankhah Posted February 20, 2012 Author Posted February 20, 2012 Lee, you are very swift , thank you very much for all your helps . Quote
Lee Mac Posted February 20, 2012 Posted February 20, 2012 You're welcome Mehrdad, let me know how you get on Quote
Ahankhah Posted February 20, 2012 Author Posted February 20, 2012 You're welcome Mehrdad, let me know how you get on It works excellent. Quote
Ahankhah Posted February 27, 2012 Author Posted February 27, 2012 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. Quote
Ahankhah Posted February 27, 2012 Author Posted February 27, 2012 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). Quote
Lee Mac Posted February 27, 2012 Posted February 27, 2012 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 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.