Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
EC-CAD
Posts: 5,930
Registered: ‎12-12-2003
Message 1 of 7 (963 Views)
Accepted Solution

Set Annotative using Lisp or VLisp

963 Views, 6 Replies
12-16-2011 08:12 AM

Hey all, it's been awhile since I was last here..

I need a way to get / set the Annotative Property of a Dimension.

The one shown under: 'Properties, Dimension, Misc(tab), 'Annotative (Yes,No)

If I use a DimStyle that has been set to Annotative, no problem, comes up as Yes.

If I use a DimStyle that is not set, but pick a Dim, I can manually toggle to Yes.

 

So, where is the 'IsAno' bit set ?

Be kind now :smileyhappy:

Bob

 

And in case you're wondering how i would set  an object to Annotative

 

Use change or chprop

 

(defun c:test (/ ss)
(setq ss (ssget '((0 . "DIMENSION,*TEXT"))))
(repeat (sslength ss)
(if (not
(IsAnno-p (vlax-ename->vla-object (setq e (ssname ss 0))))
)
(command "_chprop" e "" "A" "Yes" "")
)
(ssdel e ss)
)
)

HTH

 

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 2 of 7 (932 Views)

Re: Set Annotative using Lisp or VLisp

12-17-2011 03:34 AM in reply to: EC-CAD

EC-CAD wrote:

Hey all, it's been awhile since I was last here..

I need a way to get / set the Annotative Property of a Dimension.

The one shown under: 'Properties, Dimension, Misc(tab), 'Annotative (Yes,No)

If I use a DimStyle that has been set to Annotative, no problem, comes up as Yes.

If I use a DimStyle that is not set, but pick a Dim, I can manually toggle to Yes.

 

So, where is the 'IsAno' bit set ?

Be kind now :smileyhappy:

Bob

 


(defun IsAnno-p (ent /  exd ano)
(vl-load-com)  
    (and (eq (vla-get-HasExtensionDictionary ent) :vlax-true)
	   (setq exd (vla-GetExtensionDictionary ent)
		 exd (vla-item exd "AcDbContextDataManager")
		 ano (vla-item exd "ACDB_ANNOTATIONSCALES")
		 )
	   (not (zerop (vla-get-Count ano)))
	   )
  )

 

  

(IsAnno-p
  (setq itm (vlax-ename->vla-object (Car (entsel))))
  )

 

HTH

 

EDIT:    Smileys

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 3 of 7 (924 Views)

Re: Set Annotative using Lisp or VLisp

12-17-2011 04:53 AM in reply to: pbejse

And in case you're wondering how i would set  an object to Annotative

 

Use change or chprop

 

(defun c:test (/ ss)
  (setq ss (ssget '((0 . "DIMENSION,*TEXT"))))
  (repeat (sslength ss)
    (if	(not
	  (IsAnno-p (vlax-ename->vla-object (setq e (ssname ss 0))))
	  )
      (command "_chprop" e "" "A" "Yes" "")
      )
    (ssdel e ss)
    )
  )

HTH

 

Valued Mentor
alanjt_
Posts: 483
Registered: ‎08-25-2008
Message 4 of 7 (922 Views)

Re: Set Annotative using Lisp or VLisp

12-17-2011 05:19 AM in reply to: pbejse

I use this to check, which accounts for objects that were once annotative but are no longer..

 

(defun AT:isAnnotative (ename / check)
  ;; Check if entity is annotative
  ;; ename - ename to check (returns T if annotative)
  ;; Alan J. Thompson
  (and (setq check (cdr (assoc 360 (entget ename))))
       (setq check (dictsearch check "AcDbContextDataManager"))
       (setq check (dictsearch (cdr (assoc -1 check)) "AcDb_AnnotationScales"))
       (assoc 350 check)
  )
)

 

Distinguished Contributor
EC-CAD
Posts: 5,930
Registered: ‎12-12-2003
Message 5 of 7 (890 Views)

Re: Set Annotative using Lisp or VLisp

12-19-2011 02:39 PM in reply to: alanjt_

Thanks for the rapid response, forgive the feedback.

The (IsAnno function works, no problems.

 

When using    (command "_chprop" ent "" "A" "Yes" ""); Set to Annotative,

If the entity is not in 'Current Space', it throws an error.

Problem may be I'm in a Paper Space Tab when I issue the command to run the routine.

 

So, now I need to figure out how to 'set' the Current Space ?

 

I tried something like this:

 (defun set_current_space ( cur_lay / acad acdoc )
  (vl-load-com)
   (setq acad (vlax-get-acad-object)
      acdoc (vla-get-ActiveDocument acad)
   ); setq
   (if (not (= cur_lay "Model"))
     (vla-put-ActiveLayout acdoc cur_lay)
   ); if
 ); function

..

Didn't get it done. Still errors.

 

Thanks to all whom responded.

Bob


 

Valued Mentor
alanjt_
Posts: 483
Registered: ‎08-25-2008
Message 6 of 7 (884 Views)

Re: Set Annotative using Lisp or VLisp

12-19-2011 06:17 PM in reply to: EC-CAD
(defun _setLayoutFromEName (ename) (setvar 'CTAB (cdr (assoc 410 (entget ename)))))

 

(_setLayoutFromEName (car (entsel)))

 

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 7 of 7 (880 Views)

Re: Set Annotative using Lisp or VLisp

12-19-2011 08:14 PM in reply to: EC-CAD

EC-CAD wrote:

Thanks for the rapid response, forgive the feedback.

 

When using    (command "_chprop" ent "" "A" "Yes" ""); Set to Annotative,

If the entity is not in 'Current Space', it throws an error.

Problem may be I'm in a Paper Space Tab when I issue the command to run the routine.

 

Bob


 

Listen, changing Text/Dimensions to Annotative on paperspace tab doesnt do you any good, as a matter of fact it doesnt make any diffrence at all.

 

But for your reference:

use (layoutlist);<-------

 

(defun  c:test (/ ss)
  (vl-load-com)
  (setq curtab (getvar 'Ctab))
  (foreach
     tb (cons "Model" (layoutlist))
    (setvar 'Ctab tb)
    (if (setq
          ss (ssget "_X" (list '(0 . "DIMENSION,*TEXT") (cons 410 tb)))
          )
      (repeat (setq i (sslength ss))
        (if (not
              (IsAnno-p
                (vlax-ename->vla-object
                  (setq e (ssname ss (setq i (1- i))))
                  )
                )
              )
          (command "_chprop" e "" "A" "Yes" "")
          )
        )
      )
    )
  (setvar 'ctab curtab)
  (princ)
  )

The code above will not give you error message, but it wont change the Annotative properties of the entities selected.on paperspace.

 

try to change TEXT annotative prperty using chprop via command line .

 

Can not be set to Annotative in PaperSpace.

 

Of course  you can  set annotative on/off via _properties but then again ti doesnt make a diffrence on the behavior of those entities.

 

IMO better set paperpspace entiteis to NO, it matters somewhat  with prinitng depending on your textstyle settings

Match text orientation to layout. <------

 

personally I wouldnt even use annotative on paperspace, so if your company annotates drawon paperpspace Annotative or not wouldnt make a difference, but thats just me. 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.