AutoCAD Visual LISP / AutoLISP :: Search A Block Quickly
Feb 2, 2012
to verify if a block exists in the drawing, use the following function, which for is too slow.Is there a faster way to search for a block?
(defun findblock (cerca / blk nomebl trovato) (setq blk (tblnext "BLOCK" 1)) (while blk(progn setq nomebl (cdr (assoc 2 blk)))(if (= nomebl cerca) (setq trovato T) ) ;-(setq blk (tblnext "BLOCK")) ) ) trovato)
View 2 Replies
ADVERTISEMENT
Dec 9, 2011
any code that can search for a layer using wildcards?
In my specific case, I have multiple layers than begin with "MECA" followed by a job code. I'm trying to code something that will check to see which of those layers is on, then return the layer name.
View 1 Replies
View Related
Jul 30, 2013
I'm trying to get the file name of a file outside the search path. Obviously (findfile) is not an option. The file location changes with each project so adding a search path is also not an option. I can get the path to the file but i can't seem to figure out how to get the file name. I can also get the first set of characters, as they are constant from project to project, it's just the end of the file name that changes. The file is always a PDF.
View 9 Replies
View Related
Dec 17, 2013
I'm using a Lisp which searches a certain folder and then updates all blocks, which are nested in that folder.
My issue is, that I'd like to use more than one folder on different path, where the LISP can search for this files. Is there a way to use multiple search path?
The code I'm using now to search for the blocks is: (setq dir "I:\AutoCAD Blöcke\Template\Support")
View 9 Replies
View Related
May 21, 2013
I'm working out a LISP for searching my entire drawing for a MLeader with a given value and then do something if it is found.
Currently, my code dies with
; error: Automation Error. Description was not provided.
I do not know what is going wrong & I don't know what must be done next.
(DEFUN ML-SRCHSTR (TXT LBL / SS n_txt_LBL ENT P1 P2) ;|(ML-SRCHSTR TXT)|; (IF (SSGET "x" '((0 . "MULTILEADER"))) (PROGN (SETQ ss (VLA-GET-ACTIVESELECTIONSET (VLA-GET-ACTIVEDOCUMENT (VLAX-GET-ACAD-OBJECT)))) (VLAX-FORent ss(IF (VL-STRING-SEARCH txt (STRCASE (VLA-GET-TEXTSTRING ent))) (PROGN (VLA-CLEAR ss) (INITGET 1 "Yes No") (SETQ n_txt_LBL (STRCAT "
=>> " LBL " Label EXISTS! Add another " txt "? ") y_n (GETKWORD (strcat n_txt_LBL " [Yes/No]: ")) ) (IF(= y_n "Yes") (PROGN (ppa-L-
[Code]...
My MLeader has a _TagBox & it is the attribute of the _TagBox that I am trying to check/compare the "txt" value.
View 8 Replies
View Related
Jul 11, 2013
1) I want to search the drawing for the pre-define block names given in the program.
2) If the are there, I want to replace them with the new version.
3) Program replaces the first block it finds, then tries to insert that block.
View 9 Replies
View Related
Sep 18, 2013
Some of our 64-bit users lose their custom Support File Search Paths.
After reading about it, I saw that I could add them back in by putting
(setenv "ACAD" "S:\Fonts;S:\Acad2007\Hatch_Patterns;S:\Acad2007\Lisp;S:\Acad2007\Simpson\Menu;”)
at the end of acad2013.lsp.
1. However, I get malformed string on input error in AutoCAD.
2. My other question is do I need to list only the custom paths or all of the built-in paths as well?
View 1 Replies
View Related
Jul 22, 2013
I used this snip it to add the path for network tool palettes. It works but it keeps adding the same search path every time i open a new session of AutoCAD. The list keeps getting longer with the same information. Say you want to make sure your users all have a certain tool palette.
(setq tooldir "z:\1111\2222\test]" toolpaths (vlax-get-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Files) 'ToolPalettePath))(if (not (vl-string-search tooldir toolpaths)) (vlax-put-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Files) 'ToolPalettePath (strcat (vl-string-right-trim ";" toolpaths) ";" tooldir) ))(setq tooldir nil toolpaths nil)
View 3 Replies
View Related
Nov 8, 2013
I have a simple lisp routine that loads everytime one of my users opens a new drawing, It sets the printer paths, sets the template paths and sets a bunch of environment variables
One thing I would like to add to this lisp routine is the ability to add support file search paths.
Is there a simple setenv variable for this? or is it more complicated?
View 2 Replies
View Related
Dec 6, 2013
Is there a way to search the database/tables/whatever to determine if new layers are present in a drawing?
I want to run a script to reconcile new layers in the sheet drawings after having cleaned the xref drawings, and the script bombs if there are no new layers present in the parent drawing.
If I could determine what triggers the layereval/layernotify sequence (tblsearch?) I could include an if or while lisp routine that would invoke the layer command and then reconcile the new layers.
View 9 Replies
View Related
Oct 3, 2013
I get an AutoCAD drawing from my conveyor manufacturer who have buried a block (tagname) in all of their conveyor blocks.
The only way to remove them is to manually use BEDIT and erase the tagname block.
Is there a way through Autolisp to search all blocks in a drawings and if the tagname block is part of the definition of the conveyor block, erase the tagname block or redefine the conveyor block without the tagname block.
View 8 Replies
View Related
Mar 8, 2013
When dynamic blocks are inserted they're assigned an anonymous block name. I'd like to be able to retrieve the name of the parent block after selecting the block on screen using AutoLisp.
Need a bit of code that handles this?
View 3 Replies
View Related
Apr 5, 2013
Create a routine that looks for a block based on a portion of that block name, using a specified path or search path.
For example, block to search for is BLOCKABC123, so if someone inputs ABC or 123 as a block name, it will locate that block within that folder and inserts it into the drawing at a user specified location.
Ideally, if there is a check in that if it finds more than one match, then perhaps it flags or prompts you to choose 1, 2, or 3 option which block to use. But I can live without this special function if it requires too much time to code.
View 8 Replies
View Related
Feb 12, 2012
I need to match few attribute values from one block to different block. I download a lisp file called; ca.lsp which can match the single attribute value. I modified it for more than one attribute value matching. It is ok but still wish to overcome two issues for batch prcess
1. picking up the blocks by selection
2. click the alternative block numbers of times to match the numbers of attribute values I needed.
How to modify this lisp I can run it by block name selections instead of picking selection which enable me to run batch process for numbers of drawing? That will be good...
Lisp & Demo file attached (Match attribute value, A, B & C to Attribute 1, 2 & 3).
View 3 Replies
View Related
Apr 18, 2013
I am learning autolips and i found a problem that i can´t solved.
(vl-load-com)(defun c:pmb ( / ss ent pt )(prompt "
selec block : ")(setq ss (ssget '((0 . "INSERT")))) (setq ent (ssname ss 0)), (setq pt (cdr (assoc 10 (entget ent)))) (command "point" pt))
wich this code you select one block and insert one point at insert point´s block.
which this other code yo select all block and insert all point.... but in one block
(vl-load-com) (defun c:pmb11 ( / sele cod bloque nbloque lista pt ) (prompt "
block: ") (setq sele (ssget ( List'(0 . "INSERT"))) Cod 0 )cod (1+ cod) (repeat (sslength sele) (setq bloque (ssname sele cod)) (setq pt (cdr (assoc 10 ( entget bloque)))) (command "punto" pt) );repeat )
View 4 Replies
View Related
Nov 30, 2012
I have a block that i want to insert several times and revised each one to be different to do this i would have to insert it and rename the blocks that come in and then reinsert i would like to insert and have a lisp explode the main block and rename the other 2 blocks with a suffix at the end depending on how many times its in the drawing... can this even be done? My original block name that will be first inserted is "BENT PULLEY NOTES" it needs to explode after i drop it in and then there are 2 blocks within that called "Bent Pulley" and "Bent Pulley DYN" that i was hoping to keep the names but add a number at the end depending on how many are in the drawing already...
here is a lisp that i have found... it would work if i didn't have nested blocks and only wanted the one block to be insert and not explode...
(defun c:Test (/ e i name Bname )
(setq e nil)
(command "_.-insert" "Drawing1.dwg" pause "" "" "")
(if (setq e (entlast))
[Code] .......
View 9 Replies
View Related
Dec 23, 2013
I have a dwg with 40 blocks that have a non-annotative property. I can go through 1 by 1 and change the property to annotative and redefine the block. Is it possible to automate this? I have done some google searches but have not found anything I am able to cut and paste or put together to get it to work.
Civil 3D 2012 SP4.0 Windows 7 Enterprise 64-bit
C3D 2014 SP1
Dell M6600, Core i7 @ 2.3GHz, 16 GB ram
Dell T3500 workstation, too much ram to post
View 3 Replies
View Related
Mar 2, 2012
I am trying to select all blocks of a certian name. I am using the following:
(setq ss1bk (ssget "_X" (list (cons 2 blkname))))
My issue is that this will not select any dynamic or attribute blocks that are not at the default insert state.
how to select all of a block by name including reguardless of current state?
View 9 Replies
View Related
Sep 26, 2013
I have a routine that counts dynamic blocks by visibility state and stores that information then prompts for scale and color and stores that information. Then a legend begins to build from the data and a collection of blocks to reflect the dynamic blocks and their visibility state. Everything works great on all of the machines around the office except on one. When the legend begins building, the one user is getting the DDATTE dialog instead of allowing the values to populate as expected. So, I had him change ATTREQ to 0 an run again. No deal, the same thing happens again and again. And; it only occurs on the one machine.
View 5 Replies
View Related
Feb 21, 2013
I need to get VLA-Object from block name.
here there is a code to get block name from VLA-Object:
(vlax-get-property obj (if (vlax-property-available-p obj 'EffectiveName) 'EffectiveName 'Name) )
but I need the inverse of this code exactly:
blockname(as a string)==>VLA-object
(defun GetVLA_BName (BName).......
so, how can I do it?
View 9 Replies
View Related
Nov 27, 2013
I need to pick a nested block in drawing, I prepared this code to get name of selected blocks:
(defun c:test ( / e obj blkName)(while T (while (Not (setq e (entsel "
Select a BLOCK to edit: ")))) (setq obj (vlax-ename->vla-object (car e))) (if (= (vlax-get-property obj 'ObjectName) "AcDbBlockReference") (setq blkName (vlax-get-property obj (if (vlax-property-available-p obj 'effectivename)'effectivename 'name)) );setq );if (princ (strcat "
Block Name is: " BlkName)));while);defun
But, how to select a nested block?
View 4 Replies
View Related
Jun 17, 2013
I continue with my problems.....
I get attribute value from block and put it in a list:
(repeat (setq cnt (sslength sset))
(setq attValue (GetAttributeValue (ssname sset i) "tag1"))
(setq attValue2 (GetAttributeValue (ssname sset i) "tag2"))
[Code]...
When I try to put them in a table...
(foreach item lst
(vla-setText mytable
row 0
(last item)
)
(setq row (1+ row))
)
only put one ( attValue2) at column, and i like put 2 values, each one in a column in the same row
View 9 Replies
View Related
Aug 5, 2013
I would like to select all instances of a block, and put a new block on top of them using the same properties (insertion, rotation) but am unsure how to do this
View 3 Replies
View Related
Mar 29, 2012
I need fix a block attribute named "NrPunct.dwg"
MyProblem: after I insert the block “NrPunct” in my drawing ,, I cannot modify "textHeight", when I edit the ATTDEF (or attribute) with the command “DDEDIT” . Why?
You see my arrow in the picture pozamea.jpg…
View 2 Replies
View Related
Sep 27, 2010
We have a block contain 10 attibs to be seen with 8 differents scales making 80 attribs! (We use that before Annotative features). When we edit this block, we have a LISP that ask for the 10 avlues, and copy it for all the scale.
This lisp use the block ename in argument.
We start to use that block with MLEADER, but we can not edited with our lisp (can not find the ename of the block in the MLEADER definition ).
Is that a way to find this ename, and to be able to modify (our substitute) all the attributes value.
View 3 Replies
View Related
Feb 13, 2013
I need to delete a specific block from current opened drawing by LISP command.
for example removing XREF attached is very easy:
(COMMAND "-XREF" "D" "FRAME")
I can remove "FRAME" XREF from drawing. Now, I want to delete a/all block with "TB12" name with same action!
(command "BlockDelete" "TB12")
so, how can I delete a/all block with specific name in current drawing?
View 9 Replies
View Related
Aug 6, 2013
I have a block named "WD_MLRH". There are 3 specific attributes which I want to change in it. The attribute names are.
RUNGCNT, RUNGDIST and RUNGFIRST.
RUNGCNT will = 20
RUNGDIST will = 1.0 (or 1 will suffice)
RUNGFIRST will be decided by a user input.
Something along the lines of...
(setq RUNGFIRST (getint "Enter first rung number: "))
I'm sure this is completely wrong, but i hope that portray what I'm trying to accomplish.
View 9 Replies
View Related
Sep 5, 2012
I just need the userinput to be incorporated in the insert command but don't know how to segregate the block name from the block path..
;;;PROMPT USER FOR BLOCK NAME HERE
(setq userinBLKNAME (getstring "
Please type in the block name shown in the allrevblocks - ex: IFCC4:"))
;;;INSERT BLOCK BASED ON BLOCK NAME PROVIDED HERE
(command "-insert" "B:\CAD\REVBLOCKS\IFC\"USERINBLKNAME PAUSE "1" "" "")
View 3 Replies
View Related
Jul 16, 2013
I am trying to update my Title Block with a LISP routine (As the title implies).
So far, this is what i have...
(defun c:aTest (/ ss att)
(if (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "TB_PARAMOUNT_ELC")
(cons 66 1)(if (getvar "CTAB")(cons 410 (getvar "CTAB"))
(cons 67 (- 1 (getvar "TILEMODE")))))))
(progn
(foreach ent (mapcar 'cadr (ssnamex ss))
(setq att (entnext ent))
[Code]...
The title block, block name is static. The attribute name is static.
My ultimate goal is to copy the value of one attribute and "paste" that into the value of another attribute, and itterate this through the entire project.
View 9 Replies
View Related
May 1, 2006
Looking for starting point to writing a routine that will open blocks in a drawing and change the colour.We receive drawings from clients with their blocks and would like to have them changed to our company colours.
So basically, i am looking for something that would within a drawing, change every block to a specific color without exploding and redefining. The colour changes will be the same throughout new drawings.
View 9 Replies
View Related
Apr 22, 2013
I am trying to insert one or another block into a drawing, and i need to do this 8 times per drawing.
(defun C:detector (/ filename gas pressure)
(repeat 8 (initget 1 "Gas Pressure")
(setq filename (getkword "
Enter Detector Type [Gas/Pressure]: "))
(if (= filename "gas") (command "-insert" "*T:\acad\schematic_circuits\suny\sunygasdetectornew.dwg" pause "" "")
(or (if (= filename "pressure")
(command "-insert" "*T:\acad\schematic_circuits\suny\sunypressuretransmitternew.dwg" pause "" ""))
) ;;end or
) ;;end if
) ;;end repeat
)
View 4 Replies
View Related