Search the Community
Showing results for tags 'filter'.
-
get single block name and use a filter on the name for using inserting another block
patjeacad posted a topic in AutoLISP, Visual LISP & DCL
hello everyone, what I would like to program in lisp is the following: in the drawing I have a block (bolt) of which I want to use the name to enter another block (nut). I test for insert 0 and test for the name of the block. Because there are many lengths of, for example, an M8 bolt, the name of the block must be filtered, otherwise the correct block (nut) will not be automatically selected and placed in the drawing. see attached lisp file, with comments. (DEFUN c:nutinsert (/ A B D ) (PROGN (SETQ A (ENTSEL "\nSelect Block: ")) (IF A (PROGN ; (SETQ B (CDR (ASSOC 0 (ENTGET (CAR A))))) (IF (NOT (= B "INSERT")) (ALERT "\nselectinset is not a Block.") ) (IF (= B "INSERT") (PROGN (SETQ D (CDR (ASSOC 2 (ENTGET (CAR A))))) ;get blockname ;following are examples of bolt names, the list is much longer. I only need (IF (OR (= D "NEN1555-M08x070E") ;M8 (OR (= D "NEN1555-M06x040E")) ;M6 (OR (= D "NEN1555-M10x090E")) ;M10 (OR (= D "NEN1555-M16x100E")) ;M16 (OR (= D "NEN1568-M03x050E")) ;M3 (OR (= D "NEN1568-M08x120E")) ;M8 (OR (= D "NEN1568-M06x060E")) ;M6 (= D "NEN1555-M12x050E")) ;M12 ;I need a filter only M8 OR M6 OR M10 ECT, of the blockname. (PROGN (Setvar "Cmdecho" 0) (SETQ OLDLAYER (GETVAR "CLAYER")) (SETQ LAY (IF (NOT (TBLSEARCH "LAYER" "03_GEOMETRIE_050")) (COMMAND "LAYER" "M" "03_GEOMETRIE_050" "C" "7" "" "L" "CONTINUOUS" "" "")) ) (COMMAND "LAYER" "S" "03_GEOMETRIE_050" "") (SETQ Y (getpoint "\nGeef Invoegpunt : ")) (Command "-Insert" "NEN1560-M008-E";the BLOCK name is based on M8. ;it has to be flexible, M3 M4 M5 M6 M8 M10 ECT. Y "" "" Pause) (SETVAR "CLAYER" OLDLAYER) (PRINC) ) ) ) ) ) ) ) ) (PRINC) -
Hi, I need and thank you in advance for your help. I need to select in a drawing all types of lines except continuous. I tried to use quick select but the tool does not seem to distinguish between this style and the by layer. Thanks!
-
Goal: To select all the the objects I want to manipulate at once using a selection window, then the lisp program modifies the properties of just the Circle Entities in that selection. Below I am currently just changing the color property. After modifying the circles, I would like to modify all polyline & LWpolylines with a separate color change. I do not want to have to select the objects twice. Hopefully if this is possible I would like to followup saving Mtext or Text entites in another list. Below is where I have landed after two days of searching for solution. I am not a novice to programming but am with the lisp language. My assumption is that the ssget "_P" command can only be used once. The lisp runs and works for changes the circle entities, but not he polylines.( Command Output shown after the lisp script below) (defun c:FGT (/ ss sf1 sf2 ) (princ "\nSelect objects to export: ") (setq ss (ssget '((-4 . "<or") (0 . "CIRCLE") (0 . "MTEXT") (0 . "TEXT") (0 . "LWPOLYLINE") (0 . "POLYLINE") (-4 . "or>")))) (setq sf1 (ssget "_P" '((0 . "CIRCLE")))) (command "_chprop" sf1 "" "c" "150" "" ) (setq sf2 (ssget "_P" '((-4 . "<or") (0 . "POLYLINE") (0 . "LWPOLYLINE") (-4 . "or>")))) (command "_chprop" sf2 "" "c" "green" "" ) ) COMMAND: Command: FGT Select objects to export: Select objects: Specify opposite corner: 107 found Select objects: _chprop Select objects: 104 found Select objects: Enter property to change [Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]: c New color [Truecolor/COlorbook] : 150 Enter property to change [Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]: Command: _chprop Select objects: Command: FGT Unknown command "FGT". Press F1 for help. Command: c Unknown command "C". Press F1 for help. Command: green Unknown command "GREEN". Press F1 for help. Command: FGT Unknown command "FGT". Press F1 for help. Command: nil Command: Automatic save to C:\Users\Wesley\appdata\local\temp\Test_1_6214_5330.sv$ ... Command: Command: 'VLIDE Command: Command: Specify opposite corner or [Fence/WPolygon/CPolygon]:
-
Hello, I would apprecite some reactions on the following tools that I made. Reading about Clojure I came across functionality that is not standard available in AutoLisp. After some thinking I programmed it myself. First 2 functions which do what they are supposed to do: (defun even? (n) (and (= (type n) 'INT) (= (rem n 2) 0))) (defun odd? (n) (and (= (type n) 'INT) (/= (rem n 2) 0))) The questionmark in the functionname seems appropriate. So what to do when you want to filter a list of integers against one of these functions? I constructed the following: (defun filter (f l / a) (foreach i l (if (apply f (list i)) (setq a (append a (list i))))) a) To get you started use the following two commands: (defun c:etest () (filter 'even? (list -5 -4 -3 -2 -1 0 1 2 3 4 5))) (defun c:otest () (filter 'odd? (list -5 -4 -3 -2 -1 0 1 2 3 4 5))) Although short already I wonder if the filter routine could be made more elegant/more logical. One can extend the library with all kinds of name? functions, provided that return T or nil on every call. The questionmark and the name 'filter' are used for logic readability. Try to make a functon that returns T if a value is of type 'STR, otherwise nil. Next use it with the filter function. It's fun and would like to see the variations that you come up with. Regards, André
-
How can I filter a selection of hatch by gradient name using ssget fonction? The exeample bellow works well for standard hatch name... it does not work for gardient WORK: (setq ss (ssget "_X" (list '(0 . "HATCH")'(2 . "GRASS")))) DONT WORK: (setq ss (ssget "_X" (list '(0 . "HATCH")'(2 . "gradient")))) OR (setq ss (ssget "_X" (list '(0 . "HATCH")'(2 . "gr_spher")))) Could you help me?
-
How to select "exact" custom multileader style
rhgrafix posted a topic in AutoLISP, Visual LISP & DCL
Hi, I searched and found some code on here that did not go as deep as I need it to. A few weeks ago I made a multileader with the hexagon and enabled the large dot on the end of the leader, it was MLS "STANDARD", my first mistake. But 1st, I customized the _TagHexagon so it had a masked mtext attribute. At the time I didn't know that Quick Select and Object Selection Filters did not differentiate between home made mleaders and mleaders with mtext and a simple leader. The reason I need to separate them, sometimes I come into a dwg and all the MLs are linespace factor of 1, I want to grab them all with a filer and make them .9, looks so much better, but it also grabs my custom MLs because I left the style name as STANDARD, once they are all selected, the properties fields will not show the "line space factor" field so I have to pick each mleader, and there are a lot of them! There's nothing else unique to filter, all on layer TEXT, BYLAYER, etc. Has anyone written code to select STANDARD AND Hexagon? Or STANDARD AND MLs with leaders with dots, OR filled arrow heads etc? I am not great at lisp but I can tweak it, insert names of my own styles, blocks etc. In the mean time, I will make my new custom MLs with Color White or put the 1st one in the dwg on a different layer but I have made 30 dwgs full of these mixed MLs. Thanks much if you can help! BTW, I'm using Acad 2014 -=(RLH)=--
- select
- multileader
-
(and 3 more)
Tagged with:
-
Hello, I am in search for a means to select all blocks on a drawing given a wildcard. The particular wildcard we would be using is *- Dy I have been searching for a while now, and have seen suggestions of: Qselect, which has to be done from a dialog box, and doesn't allow the use of wildcards. Filter, doesn't seem to fit my needs because the names of the blocks don't seem to be available, only the AutoCAD name assignments ( I don't know what these are called but it labels blocks like this: U41, U42, U43, etc.) Is it possible to have a LISP select all blocks by a wildcard in the name? I am not that well versed in LISP routines, my only experience is with the beginner tutorials. Any help on this is greatly appreciated.
- 16 replies
-
- filter
- block selection
-
(and 1 more)
Tagged with:
-
Selecting Individual Layers Within XRefs
SJC2014 posted a topic in AutoCAD Drawing Management & Output
Hello, I'm a fairly new AutoCAD user (AutoCAD 2012 version) so there's probably a very simple answer to this. I have a "Master" drawing with one xref inside. Im producing drawings (layouts) from this master dwg file. Im trying to freeze individual layers within the xref, I can do this by using the Layer properties manager "VP freeze" column, this is very slow. What I would like to do is select an individual layer of the xref within the viewport and freeze it using the layer dropdown list at the top, however when I click one of the layers within the xref all the layers within the xref become selected. How can I select individual layers within the xref????? Thanks -
Hey Guys, Ive got this routine which is intended to erase everything visible which is of a colour determined by the user. (defun c:ec () (setq ecc (getint "\nEnter COLOUR of objects to ERASE : ")) (setq CODE 62) (setq pt1 '( -50000000000000 -50000000000000 -50000000000000)) (setq pt2 '( 50000000000000 50000000000000 50000000000000)) (setq ssec (ssget "w" pt1 pt2 '(list (cons CODE ecc)))) (command "ERASE" ssec "") ) The plan is to only ERASE objects which are visible at the time. So the routine should not operate on any objects on hidden layers... but should operate on objects off the screen (visible in viewport but cannot be seen due to zoom/pan position... if you follow). The problem I am having is I am finding it difficult to pass the colour variable (ecc) to the SSGET filter list while using the "W" option. If I replace "W" with the "X" option.. the routine works, but it will operate on everything in the database. So... I was just wondering if someone could please advise me of a way to filter the "W" optioned SSGET with a variable defined by the user? Thanks so much for any help. ----------EDIT--------- The problem with using the "W" option and defining the co-ordinates as I have is that it is dependant on my current UCS. I have since amended the routine to work around this issue. Please see below. (defun c:ec () (setq ecc (getint "\nEnter COLOUR of objects to ERASE : ")) (setq CODE 62) (command "ucsicon" "off" "ucs" "view") (setq pt1 '( -50000000000000 -50000000000000 -50000000000000)) (setq pt2 '( 50000000000000 50000000000000 50000000000000)) (setq ssec (ssget "w" pt1 pt2 '(list (cons CODE ecc)))) (command "ERASE" ssec "") (command "ucs" "p" "ucsicon" "on") ) Thanks guys.
-
Hi all, I want to activate a desired layer filter when beginning a new dwg or openning an existing dwg file, but calling +LAYER or -LAYER (and Filter->Set options of it) has no effects or causes Fatal Error. Who knows any alternative to set an existing layer filter as active? Note: 1- The code which causes Fatal Error is as following: (command "_.+LAYER" %filter-name% "" "") 2- This code has no effect: (command "_.-LAYER" "_Filter" "_Set" %filter-name% "") Any help or clue is greatly appreciated
-
Hey All, Is there away to filter a layer list so it doesn't show all the layers in a list box. I want to see only the "Xref-*" layers. I do need the wild card because after the hypen the names vary. Also feel free to offer other suggestions or ways to attached code.Thanks test.dcl test.lsp
-
Hi all, is there a way to define a property filter for lyers to exclude some patterns? (Assume you want to hide layers starting with "3D ", which the matching pattern in wcmatch function is "~3D *"...) Any help is appreciated.
-
I am trying to select a rectangle in a filter definition. However in the selection box I couldn't find the rectangle. What is wrong with my steps.
-
Could someone help point me in the right direction here? I want to filter a selection of polylines (contour lines) by their Z value (ie filter to get only 10' or 5' or 2' contours). I assume I need to test the Z value to see if it is a muliple of 10, 5 or 2, etc... Any hints on hhow to get this sarted? Thanks
- 30 replies
-
- contour z value
- filter
-
(and 3 more)
Tagged with:
-
filtering out identical plines from a list
jeremyearle5 posted a topic in AutoLISP, Visual LISP & DCL
I'm trying to filter out plines that are duplicates of each other from a list. I've been trying to compare 1 point in the first pline against the list of points from the other plines. They will only share a point if they are identical for this use. I've been trying to work this out on my own but it has becaome a complete mess and I know there must be a simpler way. This code works but has no way of checking the last pline. comparepts is a list of lists of the points on the plines nubpaths is a list of the pline entity names Help if you can please. (setq compctr1 0 ctr 0 numnubs (length nubpaths) nlist (list) ) (while (< compctr1 (- numnubs 1)) (setq compctr2 (+ compctr1 1)) (while (and (< compctr2 numnubs) (not reject)) (setq complngth (length (nth compctr2 comparepts))) (setq compctr3 0) (while (and (< compctr3 complngth) (not (equal (car (nth compctr1 comparepts)) (nth compctr3 (nth compctr2 comparepts)) 0.00009))) (setq compctr3 (+ compctr3 1)) ) ;_ end of while (if (/= compctr3 complngth) (setq reject T) ) ;_ end of if (setq compctr2 (+ compctr2 1)) (if (= compctr2 numnubs) (setq nlist (append nlist (list (nth compctr1 nubpaths)))) ) ) ;_ end of while (setq compctr1 (+ compctr1 1) reject nil ) ) ;_ end of while -
Ok so I'm new to the forum and I see people mentioning the filter command what does this do exactly? what are its uses? and how do I use it? Cheers Sid
-
Hi all, is it possible to filter selection set to contain only minserted blocks? If so, how? Thanks to anyone who spends her/his time to get any answer to the problem.
- 8 replies
-
- selection set
- minsert
-
(and 2 more)
Tagged with: