AutoCAD Visual LISP / AutoLISP :: Delete Block From Multiple Layouts
Apr 26, 2012I got a model-file with several layout tabs and I want to delete a block in all layout tabs.
View 9 RepliesI got a model-file with several layout tabs and I want to delete a block in all layout tabs.
View 9 RepliesWhy can't I get this to work?... okay, it is being used via AcCoreConsole.exe
I get the following...
; error: bad argument type: VLA-OBJECT nil
(defun delAllLayouts ()
(vl-load-com)
(vlax-for item
(vla-get-Layouts
(vla-get-ActiveDocument
[Code]....
I am trying to create a lisp to delete all the empty layouts from mydrawings. I do not see any code to control this.
View 8 Replies View RelatedI have a specific problem with renaming layouts. I found some similar lisps, but I just could not make them work.
In every layout I have following attributes.
PROJECT: 306
PHASE: RD
OBJECT: A0101
PART: EL
DRAWING: 611
ZOOM: X
REVISION: 01
I need to rename every each of layout using those attributes. Layout's name should look like that: "306_rd_A0101_el_611_x_01" . "rd", "el" and "x" must be written using lowercase.
Any routine to re-size viewports in multiple layouts? We have to re-size viewports as they were created a little too small and are now spread across almost 1000 drawings in 18 dwg.
View 6 Replies View RelatedI have a csv file that has the drawing names and their layout names listed in columns A and B. Before I begin a project, I have to create the Sheet List (in Excel) and the csv file. The csv file is needed because I have a lisp routine that reads the csv and updates all my Title Block attributes in all my drawings. (VERY sweet program) What I'm wanting to do, is create new layouts (using my dwt) based on the information in the csv file. So, when I start a new project all I need to do is create the base drawing files first. Then, in my csv file I've got those drawing names listed in Column A and their corresponding sheet titles (Layout names) in Column B. I run the lisp and it reads the csv and creates layouts in all those base drawings and naming the layouts with the sheet titles from column B.
Column A Column B
DRAWINGS SHEET TITLES
drawing1.dwg A100
drawing1.dwg A101
drawing"n".dwg "n"500
Etc, etc.
I'm needing a way to automate creating hundreds of layouts at once. (very time consuming).So the lisp has to be able to read a csv (or Excel--doesn't really matter) and create new layouts (using my dwt) in as many drawing files represented in column A. [and filtered so it doesn't create duplicates so I can run the routine at a later date when new sheets are added to the drawings] Captcha?
Is there any way of applying a new page setup to all the layouts at once?
View 5 Replies View RelatedI 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?
The below gets the block names of empty block records. The blocks may or may not be actually inserted in the dwg. In my case though, apparently they are nested in other blocks in the drawing I am working with... but it looks as if they are part of deeply nested block definitions and therefore cannot be purged. I checked a couple blocks (the code returns over 1000 in my case) it returns and there are no objects in its definition.
How can I force them out of a drawing - and hopefully reduce it's file size?
(defun NullBlocks (/ block *thisdwg* block nullblocks)
(setq *thisdwg* (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for block (vla-get-blocks *thisdwg*) ;iterate block table
(vla-get-Name block)
(if (= 0 (vla-get-count block))
(setq nullblocks (cons (vla-get-name block) nullblocks))
)
)
nullblocks
)
I would like to use a lisp routine to open all the files in a selected folder, search for a blocks by name, delete them, purge the drawing, save and close.
Is there a routing that can be used to do this?
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).
I need a lisp routine which will delete all the dimensions inside selected block or blocks, including nested blocks inside.
View 9 Replies View RelatedI know how to retrieve the entity information from the block, but can't figure out how to write the loop statement to loop, look for first attribute, assign to a variable, goto next attribute, assign to different variable, etc., etc...
In my research, most programs I've seen it execute the loop, assign to a variable, then print/put that data somewhere, loop again and utilize the same variable to print/put the next data somewhere.
I would like each attribute within a block to be assigned a separate variable.
how to write a LISP that enable me to direct automatic rename multiple block name?
Example is i have 3 block names as " A123 " , " A728 " , " A003 "
When i activate the LISP, it will automatic rename the block name to be " CAD1" , "CAD2" & "CAD3", whereby
the word "CAD" i can change whenever i start to use it change multipld block name.
I have several title blocks each in their own paperspace pages. Could have the attribute filled in, but more than likely only one page will have values filled in the attributes. I am looking for a VL method for finding which pages title block is filled in so that I can get those values and fill in the equivalent attributes for all of the other pages. Currently I am using a long set of :
(IF (setvar "ctab" "8.5x11") (IF(TBLSEARCH "BLOCK" "TB-8.5x11") (IF (/= "" (get-att "OWNER" "TB-8.5x11")) ; Function to read a named attribute(editblk "TB-8.5x11") ; Function to pull up the attdia(IF (setvar "ctab" "11x17") (IF (TBLSEARCH "BLOCK" "TB-11x17") (IF(/= "" (get-att "CUSTNMFIRST" "TB-11x17")) (progn ; At the last page ditch the [Code]..........
The example is just a very simplified version of what I'm doing. I just need to find the information, if it exists in any page and store it for later. Afterward, I'll fill in each page's Title Block with the stored information.
I know that this can be done much more efficiently. As I am currently flipping through the pages too much action is occurring on the screen and it makes some people nervous. With VL I should be able to run the search quietly, but I would still like to (setvar "ctab" "to the page with the filled attribute value") after the LISP is finished storing values.
I dont like to have Layouts Tab (Model, Layout1, Layout2,...) on bottom left side of AutoCad and I prefer to hide it.
Is there any system variable for that purpose? I just hide it via lisp only:
(vlax-put-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Display) 'DisplayLayoutTabs 0)
As you smart individuals can figure out, we do up drawing packages for construction that consist of several drawings, hundreds of drawings, for several modules of construction. Our process usually consists of one layout per drawing, so that the lisp guy can do a drawing count and put in sheet numbers based on how I manipulate the list of drawings in the one directory folder.
Now I have a client, despite the way we currently do things, requires that about 70% of the drawings will have multiple layouts. Now we're back in the stone ages, manually putting in sheet numbers, eating up our budget for this contract.
I am looking for a lisp that will rename all the layouts automatically. I tried the Layoutlist function but the output is not in order. Is there anyway that i can get all the layouts in a drawing from left to right order. for eg. i have layouts from layout1, layout 2........layout10). The layoutlist returns as layout1,layout10 etc...instead of layout 1 layout 2.
View 4 Replies View RelatedI am looking for a LISP to automatically rename all my layouts. I would like the first layout to say "HWY 400 (01)", second layout "HWY 400 (02)", third layout "HWY 400 (03)" ect..
View 4 Replies View RelatedI would like a routine that will determine if 'Page Setup A' is in the drawing and if so, apply 'Page Setup B' to all all layouts within the drawing. I would like to have it run upon drawing open in the ACAD.lsp
Basically we've changed our master page setup names, and now when a user switches to modelspace then back to paperspace the layout loses its configuration.
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.
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?
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.
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 )
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] .......
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
how to delete all OLE objects from drawing by most efficient way.
There are abt 150 drawings, each has from 2 to 20 or so OLE objects which need to be deleted. OLE objects are on many paper spaces.
I tried to use qselect but it selects only what is in current space.
Would need some lisp or some other methode than all can be deleted (excluding those which resides in blocks).
Tried also yto use ssx and then erase but still it deletes only what is on current space.
Just as additional info, those OLE are all pictures, not xls files for example.
There are many lisp that draw offset line but what about opposite way , I have wall of double line i need to delete one of them let's say inside wall line .
why i need to do this usually when i tracing in external program like autocad architecture or Revit or archicad i just need outline of exterior and interior walls !.
is there way that can delete the offset line ?(or within range predefined in lisp to prevent interfering of lines deletion).
I cannot purge a textstyle out of my drawing. When I run purge nothing is available.
However if I select the style from the style dialog I am able to select delete and delete the style.
When I use the method on the style (vlax-invoke-method style 'Delete). AutoCAD states:
Automation Error. Object is referenced by other object(s)
The style is defenatly not in use but may have been used in the past.
i have a small lisp and i would like for it to:
when i invoke the plot command, it will first check if there is a layer state called "Temp"if "Temp" exists, then delete "Temp", then re-create "Temp", then switch layer state temporariliy to "Plot" to plot the file, and then switch back to the "Temp" layer state againbasically, the "Plot" layer state will be set based on how the drawing(s) will plot. if a user makes changes here-n-there in the drawing, when the user wants to plot, the software will save current state as "Temp", plot using the "Plot" state, and switch back to "Temp" state at the end. all i am trying to achieve is to somehow over-write the "Temp" state. below is the LISP.
(command "undefine" "plot")
(defun clot ()
(if (layerstate-has "Temp")
(layerstate-delete “Temp”)
)
[Code]....
Civil 3D 2013 SP1, Win 7-64 bit
12GB RAM
I have some drawing that contains PHANTOM2 linetype.
I can't delete this linetype from my drawings!