Count amount of annotation scales in XRefs

Count amount of annotation scales in XRefs

jakob_holmquist
Enthusiast Enthusiast
324 Views
4 Replies
Message 1 of 5

Count amount of annotation scales in XRefs

jakob_holmquist
Enthusiast
Enthusiast

Hi!

I am trying to create a lisp that gets in some way accesses all Annotation scales that each XRef contains. I have this lisp below that counts the amount of annotation scales in the current drawing, but have not succeeded in getting access to any XRef's scale list, either by using (dictsearch (namedobjdict) "ACAD_SCALELIST")  since it only works with the active drawing or by any other method. Is it even possible?

 

(defun GetScaleListEntities (/ lst item)
  (setq lst nil)
  (foreach item	(dictsearch (namedobjdict) "ACAD_SCALELIST")
    (if	(= 350 (car item))
      (setq lst (cons (cdr item) lst))
    ) ;end if
  ) ;end foreach
  lst
)

 

0 Likes
325 Views
4 Replies
Replies (4)
Message 2 of 5

komondormrex
Mentor
Mentor

hey there,

check the code following

(defun c:get_xrefs_scale (/ insert_sset scale_list acad_dbx_object)
	(if (setq insert_sset (ssget "_x" '((0 . "insert"))))
		(progn
			(print "This drawing")
			(vlax-map-collection (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "acad_scalelist")
				'(lambda (dictionary) (setq scale_list (append scale_list (list (cdr (assoc 300 (entget (vlax-vla-object->ename dictionary))))))))
			)
			(print scale_list)
			(terpri)
			(vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
				'(lambda (insert) (if (minusp (vlax-get insert 'isxref))
									(progn
										(setq scale_list nil)
										(setq acad_dbx_object (vlax-create-object (strcat "objectdbx.axdbdocument." (substr (getvar 'acadver) 1 2)))) 
						   				(vla-open acad_dbx_object (print (vlax-get insert 'path)))
						   				(vlax-map-collection (vla-item (vla-get-dictionaries acad_dbx_object) "acad_scalelist")
											'(lambda (dictionary) (setq scale_list (append scale_list (list (cdr (assoc 300 (entget (vlax-vla-object->ename dictionary))))))))
										)
										(print scale_list)
										(terpri)
										(vlax-release-object acad_dbx_object)
									)
								  )
				 )
			)
		)
	)
	(princ)
)
0 Likes
Message 3 of 5

wispoxy
Advisor
Advisor

xref method...

(defun count-annotation-scales-in-xrefs ()
  (let ((xrefs (vla-get-Xrefs (vla-get-ActiveDocument (vlax-get-acad-object))))
        (scale-count 0))
    (vlax-for xref xrefs
      ;; Open the Xref file in the background
      ;; Access the named object dictionary of the Xref
      ;; Count the annotation scales
      ;; Increment scale-count
    )
    ;; Return the total count of annotation scales
    scale-count
))
Message 4 of 5

komondormrex
Mentor
Mentor

ai-lisped)))

0 Likes
Message 5 of 5

wispoxy
Advisor
Advisor

😅Ya just realized the function wasn't there. Hold on, hold on. I need to start testing these first.  

0 Likes