Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/06/2019 in all areas

  1. Fantastic!! Thank you so much Emmanuel. it works perfectly. Exactly what i needed
    1 point
  2. That was surprisingly doable. I started with function repath, a generic "change from -> to", but found it easiest to put most of the functionality in that function, since it already loops through all xrefs, so I renamed it repath2. Command RXRS (vl-load-com) (defun rename_file ( old-filename new-filename / ) ;; https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-AutoLISP/files/GUID-188B957C-4CDF-41C7-99BE-8080FA587F74-htm.html (if (findfile old-filename) (vl-file-rename old-filename new-filename) ) ) ;; https://www.cadtutor.net/forum/topic/39458-lisp-to-reload-xrefs-in-all-open-drawings/ (defun reloadall nil (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (eq :vlax-true (vla-get-isxref b)) (vla-reload b)) ) (princ) ) ;; change the name and path properties of the xref ;; pattern: change all XREFS to (strcat main_dwg_name "_" xref_name) (defun repath2 ( / frm to path main_dwg objDefs) (setq main_dwg (vl-filename-base (getvar "dwgname"))) ;; main dwg name, not including path or extension (princ "\n") (princ main_dwg) (setq objDefs (vla-Get-Blocks (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))) (vlax-for objDef objDefs (if (= (vla-Get-IsXref objDef) :vlax-True) (progn (setq path (strcat (vl-Filename-Directory (vla-Get-Path objDef)))) (setq frm (vla-Get-Name objDef) ) (setq to (strcat main_dwg "_" frm ) ) (rename_file (strcat path "\\" frm ".dwg") (strcat path "\\" to ".dwg") ) (princ (strcat "\nXREF file " frm " renamed to " to "\n" ) ) (vla-Put-Path objDef (strcat path "\\" to ".dwg")) (vla-Put-Name objDef to) (princ (strcat "\nXREF properties " frm " changed to " to "\n" ) ) ) ) ) ) ;; for Repath XRefS (defun c:rxrs ( / ) (repath2) ;; reload xrefs (reloadall) (princ) ) FYI, function repath + test function, not including all functions that you can find in the previous code block ;; change the name and path properties of the xref (defun repath ( frm to change_file / ) (setq objDefs (vla-Get-Blocks (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))) (vlax-for objDef objDefs (if (= (vla-Get-IsXref objDef) :vlax-True) (progn (setq path (vl-Filename-Directory (vla-Get-Path objDef))) (if (= frm (vla-Get-Name objDef)) (progn (if change_file (progn (rename_file (strcat path "\\" frm ".dwg") (strcat path "\\" to ".dwg") ) (princ (strcat "\nXREF file " frm " renamed to " to "\n" ) ) )) (vla-Put-Path objDef (strcat path "\\" to ".dwg")) (vla-Put-Name objDef to) (princ (strcat "\nXREF properties " frm " changed to " to "\n" ) ) )) ) ) ) ) ;; test (defun c:rxr ( / frm to ) (setq frm "xref") (setq to "mainfilename_xref") ;; change the filename of the xref ;; change the (name and path) properties of the xref object (repath frm to T) ;; reload xrefs (reloadall) (princ) )
    1 point
  3. Try this: (if (setq e (dictsearch (namedobjdict) "ACAD_DATALINK")) (vla-delete (vlax-ename->vla-object (cdr (assoc -1 e)))) )
    1 point
  4. Another version: ;; Zoom Extents all Layouts - Lee Mac (defun c:zea ( / app ctb doc ) (setq app (vlax-get-acad-object) doc (vla-get-activedocument app) ctb (getvar 'ctab) ) (foreach tab (layoutlist) (setvar 'ctab tab) (vla-put-mspace doc :vlax-false) (vla-zoomextents app) ) (setvar 'ctab ctb) (princ) ) (vl-load-com) (princ)
    1 point
×
×
  • Create New...