top of page
Search
rogersmarcel1980

Autocad Lisp Select Block: A Guide to Selecting and Exploding Blocks by Name



I am not aware of any option to plot selected objects or blocks. I am pretty sure that the options ar elimited to plotting areas of your drawings.The only thing i can think of to help achieve your request is to WBLOCK individual blocks out to their own files and then plotting those drawings.Greg


This entry was enough of an improvement on Tip #3751, Rename Blocks, that we thought it deserved a new entry spot. Tip #3751 allows you to rename a block in AutoCAD by picking the block to select it. This is especially handy for pasted in blocks whose name is usually something like A$CFG5D32S.




Autocad Lisp Select Block



This entry provides two big improvements. The first is that you can select the block before executing the command, and the second is that you are prompted to rename the block in a dialog box rather than at the Command line. After you load the AutoLISP file, the command name to execute is RB.


Note also in Bricscad that Quickselect will not work with Dynamic blocks, assume for the same reason. Also when you list a Dynamic Block it returns the anonymous name, but doesn't give the effective name.


It's good to have a standard routine to set up blocks. In that case it's easy to make your drawing more vivid by using 'Exchange Random'. You will have to make two selections of blocks. The first selection are the blocks in your drawing. The second selection are sample blocks, different types of blocks. As soon as you confirm the second selection the command will exchange every block in the first selection you make with a block randomly picked from the second selection you made creating a variety of blocks. The blocks are completely random but you can influence the result. When you select blocks named "block A" and "block B" once and "block C" twice, the command will place about twice as many blocks called "block C" then the blocks called "block A" and "block B".


Entry:ERAApplies to:blocksEffect:Replace selected blocks randomly with predefined blocksTags:block, exchange, random, ratioCategories:Blocks, randomisersSuitability:No additional suitability information Watch on YouTube


Hope that helps.Thanks,- Randy Randy Kintzley AutoCAD Express Tools Developer (formerly Bonus Tools) randy.k...@autodesk.com ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun c:attselect ( / ss2 ss tag val n na)(setq ss2 (ssadd))(sssetfirst nil nil)(princ "\nSelect blocks containing attributes.")(if (setq ss (ssget '((0 . "INSERT") (66 . 1)))) (progn (setq tag (getstring "\nEnter the TAG search specification : ") val (getstring T "\nEnter the VALUE search specification :") );setq (if (equal tag "") (setq tag "*") );if (if (equal val "") (setq val "*") );if (setq n 0) (repeat (sslength ss) (setq na (ssname ss n)) (if (sample_att_match na tag val) (setq ss2 (ssadd na ss2)) );if (setq n (+ n 1));setq );repeat (if (equal (getvar "cmdnames") "") (sssetfirst ss2 ss2) (command ss2) );if );progn then);if(princ));defun c:attselect;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun sample_att_match ( na tag val / e1 a b flag) (while (and (setq na (entnext na)) (setq e1 (entget na)) (not (equal (cdr (assoc 0 e1)) "SEQEND")) (not flag) );and (if (equal (cdr (assoc 0 e1)) "ATTRIB") (progn (setq a (cdr (assoc 2 e1)) ;2 is tag b (cdr (assoc 1 e1)) ;1 is value );setq (if (and a (wcmatch a tag) b (wcmatch b val) );and (setq flag T);then jump out of the loop );if );progn then attrib );if );whileflag);defun sample_att_match(princ "\nType ATTSELECT to run")(princ)


Bilal Issa e-mailed a request for a routine to fill an arbitrary area such as a circle, polygon, rectangle, triangle or closed polyline with an array of symbols or blocks. The routine should offer a choice of row and column spacing and should present a list of available blocks from which to choose in the current drawing. The blocks should appear as individual objects so they can be selected and adjusted later. Some typical areas to fill are shown below.


You may select a block from the list of names in the pop-up list as well as the row and column distances. The Pick Point button allows you to select anywhere inside a predefined area in the drawing. Any enclosed space is acceptable, as shown below.


The dialog box returns to the screen so that you can select any item in any order. When the dialog box selections have been made, click OK to see the area filled with an array of the selected block as shown below.


The results for a variety of shapes are shown below. The resulting array depends on the shape of the area selected. The rectangular area produces a rectangular array of blocks, and the other shapes produce a series of equally spaced blocks adjusted to the left side of the area shape.


The AutoCAD Hatch command is put to good use to define the set of horizontal lines at a spacing provided by the ROWDIST variable, denoting the distance between rows. The hatch pattern is created on a layer ARR-HATCH to contain the individual lines created by exploding the hatched area. These lines are collected in a selection set, which is used inside a repeat loop. The Measure command is used to insert the chosen block on each line at equal intervals given by the COLDIST (column distance) variable. The lines are then deleted one by one after the blocks have been placed so the end result is an array of individual blocks.


nice lisp. having the Ability to Change Visibility States in this lsp would be great. Such as having a dynamic block for drawing issues and being able to change visibility states automatically would be a great add on to this lisp. 2ff7e9595c


0 views0 comments

Recent Posts

See All

Google Play Store Apk 8

Google Play Store APK 8: Como baixar e instalar no seu dispositivo Android Se você é um usuário do Android, provavelmente sabe que a...

Comments


bottom of page