Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/10/2024 in all areas

  1. probably not exactly what you want but should be relatively easy to modify to copy to all open drawings ;;; copy to drawing (defun ctd ( ss dwg / ss->ol dbx_ver acApp acDoc dbx object-list object-safe-array) (defun SS->OL (ss / i l) (setq i 0)(repeat (sslength ss)(setq l (cons (vlax-ename->vla-object (ssname ss i)) l) i (1+ i))) l) (defun dbx_ver ( / v) (strcat "objectdbx.axdbdocument" (if (< (setq v (atoi (getvar 'acadver))) 16) "" (strcat "." (itoa v))))) (setq acApp (vlax-get-acad-object) acDoc (vla-get-ActiveDocument acApp)) (setq dbx (vl-catch-all-apply 'vla-getinterfaceobject (list acApp (dbx_ver)))) (vla-open dbx dwg) ; put all block objects in a list (foreach object (ss->ol ss) (setq object-list (cons object object-list))) ; put list with objects in a safe array (setq object-safe-array (vlax-make-safearray vlax-vbobject (cons 0 (1- (length object-list))))) (vl-catch-all-apply 'vlax-safearray-fill (list object-safe-array object-list)) ; copy objects to wblock-dbx-container (vla-CopyObjects acDoc object-safe-array (vla-get-ModelSpace dbx)) (vl-catch-all-apply 'vla-saveas (list dbx dwg)) (vl-catch-all-apply 'vlax-release-object (list dbx)) (setq object-list nil object-safe-array nil) (princ) ) (defun c:t1 ( / ss dwg ) (if (and (setq ss (ssget))(setq dwg (getfiled "Copy objects to :" (getvar 'dwgprefix) "dwg" 0)))(ctd ss dwg))(princ)) maybe : ;;; copy to all open doc (defun ctaod ( / ss ss->ol dbx_ver acApp acDoc dbx object-list object-safe-array) (defun SS->OL (ss / i l) (setq i 0)(repeat (sslength ss)(setq l (cons (vlax-ename->vla-object (ssname ss i)) l) i (1+ i))) l) (defun dbx_ver ( / v) (strcat "objectdbx.axdbdocument" (if (< (setq v (atoi (getvar 'acadver))) 16) "" (strcat "." (itoa v))))) (setq acApp (vlax-get-acad-object) acDoc (vla-get-ActiveDocument acApp)) ;;; select objects (setq ss (ssget)) ; put all objects in a list (foreach object (ss->ol ss) (setq object-list (cons object object-list))) ; put list with objects in a safe array (setq object-safe-array (vlax-make-safearray vlax-vbobject (cons 0 (1- (length object-list))))) (vl-catch-all-apply 'vlax-safearray-fill (list object-safe-array object-list)) ;;; copy objects to all open docs except active doc (vlax-for x (vla-get-documents (vlax-get-acad-object)) (if (not (eq x acDoc)) (progn (vla-CopyObjects acDoc object-safe-array (vla-get-ModelSpace x)) (vla-save x) ) ) ) (princ) )
    1 point
  2. I do remember BricsCAD execute lisp code to other drawings that where already open. --edit found the post but it didn't work in AutoCAD back then either. ;;----------------------------------------------------------------------------;; ;; Copy Selection to All open Drawings works in BrisCAD ;; https://www.cadtutor.net/forum/topic/86226-returning-focus-to-excel-after-lisp-ends/ (defun C:Copy_to_All_Drawings () (C:C2AD)) (defun C:C2AD (/ ss x) (vl-load-com) (setq ss (ssget)) (vl-cmdf "_.Copybase" "_non" "0,0" SS "") (vlax-for x (vla-get-documents (vlax-get-acad-object)) (vla-SendCommand x (strcat "_.pasteclip pause")) ) (princ) )
    1 point
  3. You can set a "place holder" right before creating or modifying things in the drawing. using entnext to add each to the selection set. (setq ss (ssadd)) ; Create an empty selection set (setq LastEnt (entlast)) ; Get the last entity in the drawing ; code to add items (while (setq LastEnt (entnext LastEnt)) ; Add all entity's created/modified after setting lastent to the selection set (ssadd LastEnt ss) )
    1 point
  4. "add objects in SS while i'm creating them, in a lisp," Look into lisp function SSADD you should be able to add (entlast) to ss. (setq ss (ssadd)) ; makes a blank selection set do stuff (setq ss (ssadd (entlast) ss))
    1 point
×
×
  • Create New...