Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/13/2025 in all areas

  1. Slight different way of looking at this - back to OPs original problem of how to select the entities - instead of insert and explode, load the block into the drawing and grab the entities it contains from there. The block doesn't need to be inserted, that can come shortly. This will insert the exploded block (for most simple entities, not tested fully) The selection set MyAllSS contains all the inserted entities, so I think (command "join" .... ) will join everything together You'll have to adjust the BlockName list. (defun c:SSBlockEntities ( / BlockName acount MyEnts MyAllSS MySS MyEnt NewEnt) ;;Sub routines ;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-select-all-entities-inside-of-a-block/td-p/10284294 (defun blockcomponents ( blk / ent rtn ) (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (setq rtn (cons ent rtn)) ) ) (reverse rtn) ) ;; End subroutines (setq BlockName '( "CircuitBreaker" "CT")) ;; Block Names to assess (setq MyAllSS (SSAdd)) ;; Blank Selection set - all entities, all blocks (foreach n BlockName (setq MySS (SSAdd)) ;; Blank Selection set (setq acount 0) ;; A counter (setq MyEnts (blockcomponents n)) ;; Entity list for block (while (< acount (length MyEnts)) ;; Loop this block (setq MyEnt (entget (nth acount MyEnts))) ;; nth entity description (setq NewEnt (entmakex MyEnt)) ;; Make a new entity (ssadd NewEnt MySS) ;; Add entity to selection set (ssadd NewEnt MyAllSS) ;; Add entity to selection set - all entities, all blocks (setq acount (+ acount 1)) ;; Increase Loop ) ; end while ;; Or do command 'Move' and 'rotate' on MySS selection set here: (command "move" MySS "" '(0 0 0) pause "") (command "rotate" MySS "" (getvar 'lastpoint) pause) ) ; foreach n (princ) ; exit quietly )
    1 point
  2. Haven't looked at the code but FYI. Entity names are generated when the drawing is open making them unique and random and only valid for that drawing. You can't save an entity name's and call it later when a drawing is closed or use entget with that entity name from another drawing. -edit So a circle in two drawings with everything the same layer, color, xyz location will have two different entity names. <Entity name: 1A3F5B7C> <Entity name: 2B8E4D9A>
    1 point
  3. We invent a "bicycle", but it turns out that it already exists in an ideal version. ObjectBreakV1-0.lsp Thanks, Lee Mac!
    1 point
  4. (vl-load-com) (defun c:FOO (/ *error* acDoc ss pt y item data blocks) (defun *error* (msg) (if ss (vla-delete ss)) (if acDoc (vla-endundomark acDoc)) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (if (and (ssget "_:L" '((0 . "INSERT"))) (setq d (getreal "\nEnter Block distance: ")) ) (progn (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) (vlax-for x (setq ss (vla-get-activeselectionset acDoc)) (setq pt (vlax-get x 'insertionpoint)) (if (setq item (assoc (setq y (cadr pt)) data)) (setq data (subst (cons (car item) (append (cdr item) (list x))) item data) ) (setq data (cons (cons y (list x)) data)) ) ) (if data (foreach item data (setq blocks (vl-sort (cdr item) (function (lambda (a b) (< (car (vlax-get a 'insertionpoint)) (car (vlax-get b 'insertionpoint)) ) ) ) ) ) (setq pt (vlax-get (car blocks) 'insertionpoint)) (foreach block (cdr blocks) (vla-move block (vlax-3d-point (vlax-get block 'insertionpoint)) (vlax-3d-point (setq pt (polar pt 0.0 d))) ) ) ) ) ) ) (*error* nil) ) This works for each group of Blocks at a given Y level, based on the lowest X position in a given row as starting point.
    1 point
  5. try this : (defun Fill_Toolbar_Background (x- y- x+ y+ c / y vws bgf-fac delta-y) (setq y y- vws (getvar "viewsize") bgf-fac (/ 0.1 (/ (atof GrM-Button-Background-Fill) 100.0))) (setq delta-y (/ vws 1000.0)) (while (<= y y+)(grdraw (list x- y)(list x+ y) c)(setq y (+ y (* delta-y bgf-fac (/ vws start-viewsize)))))) did very little testing though... oh , about the 'duplicated' background fill , although there are two and the first could (should) have been deleted, it doesn't matter because lisp only evaluates the last version. Every new definition overwites the previous one.
    1 point
×
×
  • Create New...