Jump to content

Leaderboard

Popular Content

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

  1. (defun c:foo (/ a b c d e l n p pr s) (defun _wf (fn l / f) (cond ((and (eq 'str (type fn)) (setq f (open fn "w"))) (foreach x l (write-line x f)) (close f) fn ) ) ) (setq pr "RG") (cond ((and (setq s (ssget "_a" (list '(0 . "lwpolyline") '(90 . 4) (cons 410 (getvar 'ctab)))))) (setq l '("ID,LENGTH,WIDTH")) (setq n 0) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (vla-getboundingbox (vlax-ename->vla-object x) 'a 'b) (setq c (mapcar 'vlax-safearray->list (list a b))) (setq d (vl-sort (mapcar 'abs (mapcar '- (car c) (cadr c))) '>)) (setq p (mapcar '+ (mapcar '/ (mapcar '+ (car c) (cadr c)) '(2. 2.)))) (entmakex (list '(0 . "TEXT") '(100 . "AcDbEntity") '(8 . "ID_Text") '(100 . "AcDbText") (cons 10 p) (cons 40 (cadr d)) (cons 1 (setq e (strcat pr (itoa (setq n (1+ n)))))) '(50 . 0.0) '(41 . 1.0) '(51 . 0.0) '(7 . "Standard") '(71 . 0) '(72 . 1) (cons 11 p) '(210 0.0 0.0 1.0) '(100 . "AcDbText") '(73 . 2) ) ) (setq l (cons (strcat e "," (vl-princ-to-string (car d)) "," (vl-princ-to-string (cadr d))) l) ) ) ;; Writes CSV text file to same directory as drawing (_wf (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".csv") (reverse l)) ) ) (princ) ) (vl-load-com)
    1 point
  2. Please try the following: (defun c:exnest ( / doc ent ) (while (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (/= "INSERT" (cdr (assoc 0 (entget ent)))) (princ "\nSelected object is not a block.") ) ) ) ) (if ent (progn (vlax-for obj (vla-item (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (LM:name->effectivename (cdr (assoc 2 (entget ent)))) ) (exnest:explode obj) ) (vla-regen doc acallviewports) ) ) (princ) ) (defun exnest:explode ( obj / lst ) (if (and (= "AcDbBlockReference" (vla-get-objectname obj)) (vlax-write-enabled-p obj) (not (vl-catch-all-error-p (setq lst (vl-catch-all-apply 'vlax-invoke (list obj 'explode))))) ) (progn (foreach obj lst (exnest:explode obj)) (vla-delete obj) ) ) ) ;; Block Name -> Effective Block Name - Lee Mac ;; blk - [str] Block name (defun LM:name->effectivename ( blk / rep ) (if (and (wcmatch blk "`**") (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk)))) '("AcDbBlockRepBTag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (cdr (assoc 2 (entget rep))) blk ) ) (vl-load-com) (princ)
    1 point
  3. you have found one way to update blocks. I don't use design centre but I think what you have suggested is correct. As for adding attributes to existing blocks you have to "sync" the existing block entries to the modified ones. Either use BATTMAN or ATTSYNC to do this.
    1 point
×
×
  • Create New...