Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Mentor
mdhutchinson
Posts: 2,321
Registered: ‎11-18-2003
Message 1 of 1 (369 Views)

ObjectDBX Detach XRefs AND delete all Annotation

369 Views, 0 Replies
02-22-2013 01:48 PM

What would the ObjectDBX equivelent of DeleteAllAnnotations function look like?

 

(functions below this deletes the xrefs... opening the files afterward automatically purges the xrefs from the dwg. This essentially is the same as XRefDetach.)

 

(defun DeleteAllAnnotations (/ AllAnnotation)
 (setq AllAnnotation
    (ssget "X"
       '((-4 . "<OR")
         (0 . "AECB_LABEL_CURVE")
         (0 . "MULTILEADER")
         (0 . "MTEXT")
         (0 . "AEC_POLYGON")
         (0 . "POLYLINE")
         (0 . "LEADER")
         (0 . "AEC_SCHEDULE_TABLE")
         (0 . "DIMENSION")
         (0 . "LWPOLYLINE")
         (0 . "CIRCLE")
         (0 . "LINE")
         (0 . "ELLIPSE")
        (-4 . "OR>")
        )
    )
 )
 (command "erase" AllAnnotation "" "")
)

 

 

*****************************************

Detach Xrefs below...

 

(defun c:RemoveXRefsFrom ()
 (setq pat (getfiled "Select filename to get path" "P:\\" "" 4))
  (setq pat (vl-filename-directory pat))
  (setq fils (vl-directory-files pat "*.dwg"))
  (foreach fil fils
  (setq PathDwgName (strcat pat "\\" fil))
  (RemoveXRefs PathDwgName)
 )
)
;;; (RemoveXRefs "X:/!TWC_Cad/2013/Transfer/TestObjDBX/HostDwgToPrepare.dwg")
(defun RemoveXRefs (file / acapp odbx opendoc blkinfo blkname blkobj dbxdoc group)
 (vl-load-com)
 (if (setq file (findfile file))
  (progn
   (setq acapp (vlax-get-acad-object))
   (setq odbx (vla-getinterfaceobject
          acapp
          (strcat "ObjectDBX.AxDbDocument."
              (itoa (atoi (getvar "acadver")))
          )
         )
   )
   (setq opendoc (not (vl-catch-all-error-p
              (vl-catch-all-apply 'vla-open (list odbx file))
             )
          )
   )
   (if opendoc
    (progn
     (setq dbxdoc odbx)
     (setq LastSavedBy (vla-get-lastsavedby (vla-get-SummaryInfo (vla-get-Database dbxdoc))))
     (vlax-for lt (vla-get-layouts dbxdoc)
      (vlax-for blkobj (vla-get-block lt)
       (if (and (eq (vla-get-objectname blkobj) "AcDbBlockReference")
             (vlax-property-available-p blkobj 'Path)
         )
        (vlax-invoke-method blkobj 'Delete)
       )
      )
     )
     (dbxsave odbx)
    )
   )
   (if odbx
    (vl-catch-all-apply 'vlax-release-object (list odbx))
   )
  )
 )
 (princ) 
)
(defun dbxsave (dbxdoc)
 (vla-saveAs dbxdoc (vla-get-name dbxdoc))
)

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.