Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ObjectDBX Detach XRefs AND delete all Annotation

0 REPLIES 0
Reply
Message 1 of 1
mdhutchinson
825 Views, 0 Replies

ObjectDBX Detach XRefs AND delete all Annotation

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

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost