Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

ObjectDBX Detach XRefs AND delete all Annotation

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community