AutoCAD Visual LISP / AutoLISP :: Delete Files Named In List
Aug 19, 2012I have list like (C:projectspr0310.dwg C:projectspr0315.dwg C:projectspr03drawings17.dwg)
Want these three files deleted from C:projectspr03.
I have list like (C:projectspr0310.dwg C:projectspr0315.dwg C:projectspr03drawings17.dwg)
Want these three files deleted from C:projectspr03.
Retrieving a list of Workspaces from menu files .cui and .cuix
The function to use is (workspacelist) which returns a list of workspace names, similar to (layoutlist) for retrieving a list of Layout names.
The functionality for extracting "WorkspaceRoot.cui" from .cuix requires copying the .cuix to .zip so that it can be accessed as a Windows compressed (zipped) folder which the Windows object "Shell.Application" provides.
Please rename the attachment to .lsp
I received the following error when I tried to post the .lsp: "The contents of the attachment doesn't match its file type."
I am in need of a LISP to freeze layers in viewports on named pages. I found the following functions to return the frozen vport, but it only returns the list of already frozen and it only works if the viewport is active; besides just listing the frozen layers isn't enough. I need to be able to supply the page/tab and a list of layers to freeze.
; by Jürg Menzi 1999(DEFUN GetFrozenLaysInVport (/ LayLst) (FOREACH memb(GetMviewInfo) (IF(= (CAR memb) 1003) (SETQ LayLst (CONS (CDR memb) LayLst)) ) ) (REVERSE LayLst))(DEFUN GetMviewInfo (/ ActVpt CurSet IDX RetVal TmpVal) (SETQIDX TActVpt (CAAR (VPORTS)) ) (IF (OR(= ActVpt 1)(= (GETVAR "TILEMODE") 1) ) (SETQ RetVal nil) (PROGN (SETQ CurSet (SSGET "X" '((0 . "VIEWPORT")))) (WHILE IDX(SETQ TmpVal (ENTGET (SSNAME CurSet 0) '("ACAD")))(IF (= (CDR (ASSOC 69 TmpVal)) ActVpt) (SETQIDX nilRetVal (CDR (ASSOC "ACAD" (CDR (ASSOC -3 TmpVal)))) ) (SETQ CurSet (SSDEL (SSNAME CurSet 0) CurSet))) ) (SETQ CurSet nil) ) ) RetVal)
Is it possible to provide the page/tab name and a list of layers as aguments to a subfunction that could either activate the viewport and freeze a list of layers, or simply freeze the layer list for the named page's/tab's corresponding vport.
Important: most of my pages/tabs contain at least two vports. The largest of the two vports is the only one I wish to change, but if the layer list is frozen on all vports (per page/tab) it will make no difference because the smaller vport only requires that layer 0 is visible.
If my windows login name is HSIMPSON and i have created HSIMPSON.lsp in a Supported Directory, how do I load that Lisp file via the command line?
I have tried:
(load "loginname")
but that doesn't work because the 'load' command seems to want an explicit name, not a variable name.
The crux of the matter is that the CANNOSCALE value needs to match an existing named scale. This lisp is part of a bigger lisp and I need to pass a variable into it. Here's what I have:
(setvar "CANNOSCALE" (strcat "1" = " (rtos variable 2 0) "'"))
But I get this error when I try to run it.
; error: bad argument type: numberp: nil
how to change the font of a specific attribute in all my blocks in a drawing. I am trying to change the INST attribute font to Arial but I have thousands of them through out my project. My other attributes that I do not want to change are using the same Style as this block so I can not simply change the style.
View 9 Replies View RelatedI'm dabbling in lisp to reduce some drafting time. I'm looking for a way to move a named block left 5 inches. The names block in this instance is "Bricks". What would be the easiest way of writing this in lisp form? I searched through the forums and I couldn't find what I was looking for. This is not after an insert command. This is a block that currently exists in the drawing template.
View 9 Replies View RelatedI've made a failed attempt to add the RIBBONCONTROL Named Views to the main Quick Access Toolbar. The Customize User Interface dialogue box (CUI) seems to allow me to drag the Named Views RIBBONCONTROL from the command list to Quick Access Toolbar 1. I don't see the "forbidden" icon and the blue insert bar shows up when I perform the drag operation.
However, I suspect there is some compatibility issue, because the command doesn't pop up when I release the mouse button at the end of the drag operation. Using command QUICKCUI and trying to drag Named Views RIBBONCONTROL directly to the Quick Access Toolbar (on screen) seems to be allowed likewise, but doesn't work also.
Using the regular View Manager Dialogue is not the kind of solution I'm looking for, because in the View Manager it takes at least twice as much mouse clicks to change to another view.
Any way to reach the desired customization? Should it be reported as a bug to Autodesk?
I have a list -
(setq List1 (list "Line A" "Line B" "Line C"))
I would like to add each item in an existing list to a new list -
(setq ListNew (list "This is some text" "This is more text"
the following is the part I can't figure out - it just adds the list to the list, not the individual items
(mapcar '(lambda (x) x) List1)))
I am looking for ListNew to be - (a list with 5 strings)
"This is some text"
"This is more text"
"Line A"
"Line B"
"Line C"
I have a list ("temp.dwg" "temp2.dwg") and would like to add the string "insert text here" into each item in the list resulting in ("insert text heretemp.dwg" "insert textheretemp2.dwg"). how would i go about doing that using LISP?
View 2 Replies View RelatedWhy 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 have a list that contains data like this,
"Tree-01-08-AA5"
"Tree-04-12-QV"
"Tree-10-30-QS"
How would I go about sorting this list by AA5, QV, QS? I know how to use vl-sort and reverse, but I do not understand how I would go about this.
I have a list like ("a.dwg" "b.dwg" "c.dwg") and an filename "b.dwg"
I want to know if the file name is a part of the list. which function must be used for this?
I need to modify the code below.
When I run the command and write the scale, I need to change the name of the scale and the ratio automatically. The ratio should always be in the format "1: #", also the name of the scale. Maybe assigning more variables with "setq", I do not know.
(defun c:test ()(setvar "cmdecho" 0)(setq name (getint "
Type the scale you need:"))(setq ratio (strcat "1:" "0.1"))(command "-SCALELISTEDIT" "Add" name ratio "Exit")(setvar "cmdecho" 1)(princ))
Here's one that I could use on that i can't figure out:
I have a list of a bunch of descriptions that looks like this:
("00.02.00" "CTD01 Mainframe PT1 (top)" "GD01")
What I am doing is grabbing the middle item and i need to break this up into 2 lines. So, my code below grabs the first 3 "words" in the second item in the list and puts them in a list, but I need to convert this back to a string.
(setq desc6a (list (car (read (strcat "(" (cadr input6) ")" )))(cadr (read (strcat "(" (cadr input6) ")" ))) (caddr (read (strcat "(" (cadr input6) ")" )))))
I tried a bunch of ways but can't get it
I've been experimenting with lists and I'm curious about the fastest / easiest way to get the next element from a list:
Currently my best shot is to wrap (member 2 '(1 2 3)) with: (car(cdr (member 2 '(1 2 3))))
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.
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?
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!
A plugging we use has just updated and loading double menus causing error messages prompting that menu already exists unable to load.
In my cui the menus are loaded in my enterprise as well as my main.
How do I keep the menu with the same name in my enterprise yet unload the one of the same name in my main (where it shouldn’t be) using lisp (I want to Automate this using lisp, since I'm not always in office at the same time as everyone else)?
I am looking for code that will delete all the properties within a DWG file.
Searching the forum, I found the following
; Remove any existing Properties
(dictremove (namedobjdict) "DWGPROPS")
However, further research (forum, testing and help system) indicates that it no longer applies to current releases of AutoCAD so my initial happiness was short-lived!
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?
How to export to a txt file a list containg all the objects on the current layer and their properties?
To be precise, I would like to export the following items from a selection of plines:
- ObjectID;
- Start Point;
- End Point;
- Vertex Points;
- Width.
Here is the code snippet from my program, I am trying to build a associative list from two regular lists in the while loop. Does ""append " or "cons" only work for simple lists? Given attributeNameList attributeValTypeList which are always of the same length
(setq listCntr 0)
(while (<= listCntr (length attributeNameList))
(setq attrTagTypeAssnList (append attrTagTypeAssnList (list ((nth listCntr attributeNameList) (nth listCntr attributeValTypeList))) ))
(setq listCntr (1+ listCntr)
)
How can I dynamically build the association list.
I've created a list and want to subtract all the values within it from another variable, and assign it to a new variable. How do I do it?
Basically, I ask for ground level (assigned to variable G1), and then any number of depths beneath that (assign to list LVLLIST), and I want to return the value of the bottom point. So it's all the values in LVLLIST added together and subtracted from G1. And assign it to a new variable BASE.
For example,
G1 = 650.00
LVLLIST = (1.23 23.26 0.13 50.23)
(setq BASE (- G1 LVLLLIST))
In the example given I have two instances to show how unique the information can be.
I would like the left column of words to be some type of drop down or list so that the user does not have to type these for each line. I don't care if it's attribute, text, mtext, just whatever gets it done.
I want to list all of loaded lisp programs in AutoCAD (both .lsp and .fas) It's easy for .ARX files: (vlax-safearray->list (vlax-variant-value (vlax-invoke-method (vlax-get-acad-object) 'listarx)))
View 9 Replies View Related