AutoCAD Visual LISP / AutoLISP :: How To Detect The Blocks Which Has No Sub Entities
Nov 27, 2012
I want to code this lisp. The problem which I face is, In some drawings which come from the client, there are a lot of blocks.
I want to detect the blocks which has no sub-entities (but attribute) and add a rectangle inside this block, If it is an attribute add a line from 0,0, to insertpoint of attribute.
Any way to detect of there are objects currently selected using Autolisp, visual lisp or even VBA. I would like to be able to do something using that as a conditional, so that (assuming the hypothetical variable isSelected is an on/off indicator of whether or not something is selected) I can code something like this:
I need ot append events when the dimstyle is change using the AutoCAD dimstyle popup list, but don't know which reactoer to use. I tried with Comman begin and end, and Sysvawill change and changed, but they don't detect the dimstyle changes.
I'm putting together a simple lisp routine to issue bound, purged drawings.
I have code that will do the binding & purging but need handling the saving.
This is my approach :
(1) ask the user to save the drawing using this line (command "_saveas" "" "~")
(2) run a subroutine that binds xrefs etc (this works ok)
(3) run the QSAVE command
Trouble is, if the user cancels or hits escape during the SAVEAS command the subroutine & QSAVE will still run, overwriting the current drawing. How do I handle this scenario? Or should my appoach be different?
This is what i would like to make a lisp for: if the user gives the number tree the last tree inserted entity's are deleted. If the user gives the number four the last four inserted entity's are deleted.
I know through the block command you can write out a selection of entities to a single drawing.But what I am wondering is if it is possible to have two drawings open, and transfer data quickly between the two?
As an example as we are detailing an assembly we create a title block around a detail, put dimensions and notes on as needed and would then like that to be transfered into another drawing next to the previously transfered detail drawing.
I am having nearly 1000 drawings where I need to change the title block in a new format.
I am stuck up in moving all the entities in cordinates 15,280 (upper point) and 205,55 (lower Point) to 275,294 (upper point and correspoing lower point.
I have 2 selection sets and I'm looking for a more elegant method of checking if both sets contain the exact same entities (note - the order of entities might be different).
I have redined AutoCAD's copy command alias to C, but to also do other things, like set a few important variables in the background. One of the lisps I've incororated are making new viewports, that also create layers that are visibly specific to the viewport being created.
We were tasked a while ago to do an easy job of copying entities (dimensions, text and what not) in a layout. The problem is, users are copying the viewports too, which is bit more ineffificent than using the create viewport command I developed.
Is there a way to see if a selection set includes (0 . "VIEWPORT") entities? If the check returns nil, well then all is good. If the check returns "true", then I can prompt the user that a "VIEWPORT" entity is selected. I can then exit the command, or ask the user if they are sure they want to copy the "VIEWPORT" entity.
I have a lisp that draws variety of entities such as lines, arcs, hatches, points, blocks, text etc. How can I make one single block containing all of them, i.e. one block that has all items drawn since the lisp was invoked.
I have code that will set and sae a current UCS to the front of an entity, of course, depending on the viewpoint. This is so, because we need all draft lines in front of 3D solids, such as dimensions, leaders for labels, text entities and so on (the reason for not putting these entities in paper space is another discussion ).
But I'll have on of two problems on numerous occasions:
1. The user forgets all together to run the command. 2. The user will pick the wrong entity that is in the foremost position in that view.
Then I'll analyze the X, Y and Z of both the lower and upper corners, and set my UCS to whatever is proper.
Is there a "LowerCorner" and an "UpperCorner" for all entities. I can't see "VSMIN" and VSMAX" working because the elevation of the returned coordinates is always "0,0"
I have a lisp routing that the user has to use, to create a ucs, that is exactly on the front of the entity the user selects, so that whne they are drafting, labeling, dimensioningn the 3D entity, none of the drating lines are hidden when plotted.
Then I do a condition to see which points are greater than others, and move the ucs depending on the view to the foremost point. The program works perfectly.... however, often, they forget to use it.
I was wondering if I could incorporate it in another lisp that everyone uses, but not having the user pick the entity they want to be in front of (sometimes they pick the wrong entity). Instead, take the group of entities (anywhere between 1 to 30 per drawing (these are piping spools, so the entity count is not that great in model space)) and set a front working plane in model space. Working in paperspace is not an option, we're just too deep into our templates and processes.
I know there is a vmin and vmax, but they are for the X and Y axis, a VMax along the Z-axis would be great.
I have uploaded the handout for my AU2012 class to Google Drive. The link is [URL] It contains the detailed explanation for all the source code used in entmake-ing and entmod-ing the new MESH (aka Subdivision Surfaces) entities. [URL]
I am modifying stuff in a dynamic block insert entity. There is no "endblk" entity at the end of these definitions and I need to cycle through every entity within the block definition. When it gets to the last entity, I get an error because you cannot entnext passed the last entity. There are 2 things:
1. How to retrieve the # of entities in a block without cycling through it. Or 2. A quick lesson in the *error* function, I cannot figure out how to implement this. I basically want to to say:
(if (entnext myent)) returns a error, don't abort & continue on.
I am working on a flood inundation, I would like to find a lisp or command(i'm not finding) to connect two points with a given elevation following the surface file or surface entities.
here is a small section as example right now it's just guesswork, some of these have taken a week to connect all the sections.
(defun CELBLKS ( / e blk ss blkl) (setq blkl "" ss (ssadd)) (while (setq e (entsel "
[Code]....
i have this lsp, it works great but how can modify it if i want select with a window.? exemple: if i have 3 differentes blocks, i want to select them with windows and the lisp select all blocks that are identical of those 3.?
I have a project in 3D that I would like to export to Stadd. This requires lines rather than blocks. Is is possible to convert the blocks in the attached dwg file to to lines that are centered on those blocks?
We have this need to have all of the solids in a drawing to be placed in the "solid" layer.
Sometimes folks are drafting lines to develop these solids, and keeping the lines on the "solid" layer, rather than moving them to another layer, or deleting them altogether.
I could get folks to run this command before leaving the drawing.
I'm thinking something along the lines of:
Select all entities that are on the solids layer that are not solids.
If nil, great, do nothing.
If entities are selected, let me do something with them.
I'm hoping the following can be modified ever so slightly.
(setq non_solid (ssget "X" (list (cons 0 "3DSOLID")(cons 8 "solid"))))
I was on an older cad and am now moving to 2014.. my previous cad was heavily customized the old school way, I have decided to learn the CUI (and dynamic blocks)
My old cad has blocks on a drop down menu.. click BATH menu than WC icon, a macro sets the correct layer than inserts the WC.. took time to setup but pretty simple and straight forward (see attached for menu syntax). I also made a toolbar BATH and on that toolbar I made a WC icon.. that’s what I use the most
couple of questions
1) do I have to make a new command in CUI for each block to do the same thing? 2) I looked into the design center, but seems like its too many steps but it seems a toolbar with an icon on it, clicking the icon and a macro sets layer and insert block is still pretty quick..?? 3) if a toolbar with an icon is still a fast and less step method, can I open the block and somehow make an icon of it? if so where do I put it?
I have this code w/ which I can open up Block Library Blocks for editing. We have R2012 installed w/out VBA.Our MIS department is impossible to deal with. We have this new fangled permission hysteria so I cannot install VBA myself.Is there any other way to open up my blocks? What I can I do instead?
(defun CpL () (prompt "...Open Library Block or Xref...")(terpri) (setq a (entsel)) (setq b (car a )) (setq c (entget b)) (setq d (assoc 2 c)) (setq e (cdr d)) (setq ff (strcat e ".dwg")) (setq PP (findfile FF)) (setq opath (strcat "acadapplication.documents.open ""PP""")) (command "vbastmt" opath))
My drawing constitutes of many blocks and other objects , and i need to find specific blocks (with same block name) in my drawing which i cannot find them one by one and i though that i can find them all with lisp routine ..
so , i wanna specify point out of my drawing area and lisp routine will draw to line from basepoint of those blocks to specify point when i select one reference block.
We've recently converted all our microstation drawings to autocad now that the company has decided to go with one cad program company wide.
One of the issues we are having after getting the drawings back from the this co. converting them is the cells to blocks convertion inside the drawing. when we open a drawing and see a "Fuse" block for instance and if it a has multiple inserts, it named them:
Fuse Fuse_1 Fuse_2 etc....
is there a lisp routine or some command that would replace the "Fuse_*" blocks with "Fuse"..I've been searching the forums and know about the express tool Replace Block but need to be able to automate somehow.
I thought about trying to rename each of the "Fuse_*" but of course it won't let you rename to a block name that already exists..
I wanted to flatten arcs, circles and lines inside a block using the following lisp (which I found in this forum). I found that sometimes this lisp is unable to flatten the ARCs inside the blocks. I do not understand why it is not working for all the blocks. I have attached a drawing in which this lisp is not working.
I am looking for a routine that will replace all blocks named "DgnMisc_nodepoleind" with a block named "DgnMisc_nodepoleind2" keeping the insertion point. I could use (command "-insert" "DgnMisc_nodepoleind=Y:/ACAD2007/DA settings/Library_new_scale1/DgnMisc_nodepoleind2.dwg" NIL ) but my problem is that the block I want to replace is used on two different layers and I only want to replace the ones on layer "TPSYM01".