Leaderboard
Popular Content
Showing content with the highest reputation since 05/19/2026 in Posts
-
I've now updated this program to support resetting components of the incrementing string back to a given value with a given frequency - the latest version can be downloaded from my site: https://lee-mac.com/numinc.html7 points
-
As usual this was born out of necessity. Had a 46Mb pdf , no tools on work laptop to convert it because also no adobe (reader only). PdF was all images so AutoCad pdf attach / import won't work either. Have a (legal) tool on my own computer but pdf wouldn't fit through the mail because of IT limitations. We used to have something like One-drive / Sharepoint but also blocked now , so I wrote this app. It chops up pdf in to 10MB pieces (or any size you want) , it can also email them at the same time and at the other end of the line you can put the pieces back again with the same app. So if your IT department tries to make your life a living hell , hell , maybe this app can give you some relief. RlxSplit.lsp6 points
-
5 points
-
Just to add something more from me, as I did try to understand this problem as much as I could back then when I was working on my solution. Boundary command probably uses Pixel-Based Areas (Boundary Fill) method, that's why you have to see whole area on your screen. You can google what that is and how it works, but it makes sense to me considering there is a precision problem depending on "zoom" level. As for Hatch, it works the same for "pick points" method (boundary command + add hatch for that polyline), but if you choose "select objects" then it works as completely different method (just math without graphics part) and that's why its more accurate in this example. It all depends what you have as starting variables and what you need in the end. If you can, and its not a problem to select all lines, then CBoundray function from post above will work okay. This works like the Hatch by selecting objects... Of course clicking just one point inside area is simpler and faster, but can give wrong result because of its limitation. And I don't think its an issue with Autocad, its just a method that has its limitation. And it actually works really good otherwise, if you think about it, considering how much zoomed out you have to be and have a short segment to get the error. For example I work with topology, and have area centroids, and I needed to work some analysis with polylines for certain areas. In 99% cases boundary command was good, but with large areas with small boundary segments (like in OP example) I had this problem and needed to avoid it.4 points
-
@masao_8 Here is a solution for a simple single selection add and SHIFT-Select to remove. Perhaps this will give you a basis for starting: ;; Function to do a simple Select/Deselect using grread. ;; By PJK - 6/16/2026 (defun pjk-grread-Select (/ done en grl grc grv ss) (if acet-load-expresstools (acet-load-expresstools)) (setq ss (ssadd)) (princ "\nSelect to add objects or SHIFT+Select to remove from selection set: ") (while (not done) (setq grl (grread T 15 2) grc (car grl) grv (cadr grl) ) (cond ((= grc 3) (if (setq en (car (nentselp grv))) (if (acet-sys-shift-down) (progn (if (ssmemb en ss)(ssdel en ss)) (redraw en 4) ) (progn (ssadd en ss) (redraw en 3) ) ) ) ) ((= grc 2) (setq done (if (vl-position grv '(13 32)) T nil)) ) ((= grc 25)(setq done T)) ) ) (if (> (sslength ss) 0) (progn (foreach i (mapcar 'cadr (ssnamex ss))(redraw i 4)) ss ) nil ) )3 points
-
;;;You can call Master Leemac's code, but do not modify it (defun c:ttt(/ CPB NEW-PT OBJ PT) (c:cb) (setq cpb (entlast)) (setq pt (cdr(assoc 10 (entget cpb)))) (setq obj (vlax-ename->vla-object cpb)) (setq new-pt (vlax-3d-point (getpoint pt "\n Specify the new location"))) (vla-move obj (vlax-3d-point pt) new-pt) (princ) )3 points
-
This has been talked before if I understood the problem correctly: https://www.cadtutor.net/forum/topic/61468-boundary-precision/ To create a boundary you have to have the whole area visible in your model, everything needs to be visible in display area So it has to do something with your "viewing resolution" (zoom), that's how command works. What is the limit I don't know, I never did tests like they did in topic mentioned above. But I also had the same problems with large areas like you posted, when I have one short line, or polyline segment, one of the boundary vertices would be wrong (bad precision). The solution for me was to create lisp working with regions, then convert region to polyline. When creating regions you don't need to see the whole area on your screen, you select the lines and its just pure math from there3 points
-
@darshjalal Thanks for your program contribution. I don't want to take away for your obvious hard work, but I somewhat agree with @BIGAL. I have read the extensive comments that are very detailed and technical, but there is no summary of what it is used for, or how it is useful. For the casual LISP user, they would not understand the value in such a program. I think a simple paragraph would be help instead of blindly evaluating it. Your title does explain the purpose of the program, but it's too vague and some plain language on how the features are helpful would be nice - just a friendly critique3 points
-
I have noticed the drop in posts in forums like Lisp, here, Autodesk and Theswamp, I think it's because people are using AI more to write code. Even I try AI now and again when stuck, it is successful some times. The most obvious here is when the AI code does not work help is asked for here. Maybe Admin could comment about number of posts say compared to 1 or 2 years ago ? Or is it that a lot of new users just don't ask for help ? I know I push for process improvement and have often tried to influence people into saving time but the majority just don't care. Any body else want to comment ?2 points
-
I have mixed feelings about Clippy the AI , at least the one from Google , sure its fast and it can give some relevant answers but you have to double check everything. I am trying to create a dcl editor. Wasn't sure where to start so asked Clippy and it gave me some good ideas on where to begin. But as things got complexer it really started to mess things up. And every time you use it you need to explain every thing all over again because at least the free / unregistered version remembers (saves) nothing . But I learned from my mistakes and started to write a very extensive manual so next time I can upload that so we can better pick up from where we started. My biggest concern is that it creates a black box. You ask something , it gives you something back and you paste and test the code , great , moving on to next part. After a while you end up with a bunch of working code until it doesn't any more and that's where the trouble begins and you notice you have lost your grip on the code because Clippy did it all for you. Like your daddy did all your homework for you and you have to take the exam and ...oops , daddy aint around now is he?2 points
-
There is no doubt that AI is replacing (and will do so even more in the future) the need to interact with something or someone in order to find ideas and the motivation to pursue them. I don’t know which AI tools are the best for programming (I’ve only used Chatgpt so far), but my experience has been positive in terms of how stimulating it is to have someone to discuss ideas with and refine them while solving problems. This was something that, in the past, could only be found in forums like this one. However, the code suggested by Chatgpt is almost always lengthy and often fails. I suppose that will change over time.2 points
-
2 points
-
I would maybe start again, if you look at this https://www.lee-mac.com/polyinfo.html it will find arcs etc in plines So if you want to label Lines, Arcs, Circles and Plines, you may need different code that looks at each entiity and correctly labels. I had a quick google and found a few programs I know that Kent Cooper has something similar to Lee's, but labels each segment. Search also "forums/autodesk".2 points
-
@mhupp I use Bricscad V25 and it did not work ? Old name stayed there did I miss a step. I tried old fashioned method, it may not be the best solution, if block has attributes then could add a extra sub function to copy the existing values to the new inserted block. Also wants a "Does block exist check". ; https://www.cadtutor.net/forum/topic/99155-insert-a-copy-of-the-block-at-the-specified-point-copyrenameblockv1-5lsp-lee-mac/ ; rename a existing block to a new name ; By AlanH June 2026 (defun c:AHRenblk ( / attreqold bname ent entg inspt oldangdir oldangunits rot scx scy) (setq attreqold (getvar 'attreq)) (setq attreq 0) (setq oldangunits (getvar 'aunits)) (setvar 'aunits 3) (setq oldangdir (getvar 'angdir)) (setvar 'angdir 0) (setq ent (car (entsel "\nPick block to rename "))) (setq entg (entget ent)) (setq bname (cdr (assoc 2 entg))) (setq inspt (cdr (assoc 10 entg))) (setq scx (cdr (assoc 41 entg))) (setq scy (cdr (assoc 42 entg))) (setq rot (cdr (assoc 50 entg))) (setq newname (getstring T "\nenter new block name ")) (command "Bedit" bname "Bsaveas" newname "N" "Bclose" "S") (command "erase" ent "") (command "-insert" newname inspt scx scy rot) (setvar 'aunits oldangunits) (setvar 'angdir oldangdir) (princ) ) (c:AHRenblk) Yes will see flash on screen as Bedit is called.2 points
-
A few i had laying around ;;----------------------------------------------------------------------------;; ;; ZOOM TO OBJECT AND OUT 5% (defun C:ZZ (/ SS) (if (setq SS (ssget)) (progn (vl-cmdf "_.Zoom" "OB" SS "") (vl-cmdf "_.Zoom" "0.95x") ) ) ) ;;----------------------------------------------------------------------------;; ;; ZOOM TO OBJECT THEN OUT 25% (defun C:ZX (/ SS) (if (setq SS (ssget)) (progn (vl-cmdf "_.Zoom" "OB" SS "") (vl-cmdf "_.Zoom" "0.75x") ) ) )2 points
-
2 points
-
If it can be fixed with zooms then you can record the current zoom, zoom object, make the boundary and zoom back 'current' zoom - I think that method is online somewhere to copy / paste else can find it on Monday if needed.2 points
-
divcurve-lisp-all-option.mp42 points
-
Idk about that this is a super simple lisp that will allow you to select multiple entites. But if they aren't within the fuzz distance of each other they wont connect. ;;----------------------------------------------------------------------------;; ;; Copy Boundary Entities to join as a single polyline fuzz is 0.1 units ;; https://www.cadtutor.net/forum/topic/99146-boundary-command/ mhupp:06/04/26 (defun C:CBoundray (/ ss ss1 obj) (setq ss1 (ssadd)) (while (setq ss (ssget '((-4 . "<OR") (0 . "LINE") (0 . "ARC") (0 . "LWPOLYLINE") (-4 . "OR>")))) (foreach obj (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (vla-copy obj) ) (command "_.PEDIT" "_M" ss "" "_J" "0.1" "W" "0" "") ) (princ) )2 points
-
It's supposed to use the HPGAPTOL as far as I know. This has been an issue for sometime, now that I looked back into from a few years ago, this problem also occurs with Hatch command. I just tried Boundary and Hatch on a closed polyline object at Zoom Extents and got ... And despite the first instruction, Zooming In resolved the issue. I normally resolve this with Hatch by using Select Object, maybe Hatch, Select Object, delete the Hatch and keep the Boundary could work for the OP. @lastknownuser's post brought it back to my memory. There is a thread around from a while back on this issue and needing to use Select Object option for Hatch.2 points
-
Was reading up on this too. apparently AutoCAD boundary command doesn't have a tolerance setting but BricsCAD does. That is why people opt to use hatching and then you can create the boundary from the hatch. and then delete the hatch. I'm confused since their isn't a gap/vertex at that location.2 points
-
There was a post a couple of years ago now, if it is a closed shape without crossing lines, hatching the area then recreate the boundary and delete the hatch leaves the boundary... as a last resort since it is long winded way to go. I haven't had time this week to look at this properly - you're in safe hands with the other posters though... (The post I am thinking about was using LISP to do something, click in the area to get boundary, might have been to measure area, perimeter or something but that was the idea behind it, LISP is ok if it is a bit long winded, fractions of a second longer process)2 points
-
@Danielm103, I'm on rev. 8.9.3 so does not apply to me. Thanks for the warning nonetheless. ymg2 points
-
if Nothing else it would show up in peoples searches. just posting a file even tho it has great documentation will not show up in searches. if you take all the time to write things up and share here make it so people can find your lisp files. or just copy all the ;; lines. someone in 6 months to a year will post looking for a divide lisp with points and I won't be able to find this post. -Edit like you did here2 points
-
If your offering something a good idea is to provide images or a movie about what the program does, else the "Why bother" will occur. Just attaching a lisp is not really describing why you should download the program. Think of it as if I was selling the program how would I get people interested.2 points
-
2 points
-
Haven't checked in a while, but we can't receive any .zip, .rar, etc. in emails here, but can send them, which is useless if sending internally. They had some ridiculously low email attachment file sizes when I first came here, I got them to go to 10MB, that's most likely what it is now. I put large files to share on the network and send a link (which IT has it where it cannot be clicked on), either they figure out how to get it or they don't. Being retirement age has it's perks.2 points
-
Reminds me of when I had to move a file before networking or USB drives. had to use winrar and split up the zip file between 12 floppy disks! Was curious and it only took 17 lines of code in python lol minus the emailing and join parts.2 points
-
@darshjalal Nice work! Your added Automatic mode, and the code to strip numbers out of the text is over and above!2 points
-
@PaulyPHI Here is a quick walk-though: This uses Visual LISP to pull the text string from the selected object and convert it to a real number. See the added comments below. (if (and ;; Logical AND = All conditions must be met. ;; 1) an object must be selected. (setq es (entsel "\nSelect Text Object: ")) ;; 2) The selected object must have a text string property, i.e. TEXT, MTEXT, ATTRIBUTE, MLEADER, etc. (vlax-property-available-p (vlax-ename->vla-object (car es)) 'TextString) ;; 3) Retrieve the textsting value if the above conditions are met. (setq newZ (vla-get-textstring (vlax-ename->vla-object (car es)))) ;; 4) The textstring value must evaluate to greater than 0 when converted to a real number. This only works if the text is numerical. (> (setq newZ (distof newZ)) 0.0) ) ;; if all conditions are met, then continue to the (progn) block that performs the changes.2 points
-
Welcome. To make a cleaner look I would make a master Chart (or multiple BH SW MW or by area with a box around them) with all the relative call outs. this would allow a larger view of the area. eliminate the use/need of leaders that aren't really doing anything but cluttering the drawing. -edit Then updating would be adding borehole location and adding to the chart.2 points
-
Don't know what is going on about Textexp but here is a favour for you. I just made A-Z 0-9 exploded. Convert to correct plines then can extrude into a solid say 1 unit high, will need to check the 36 shapes. The sample dwg really needs more thought say text size =1 and height equal say 0.1. It took about 10 minutes to make these. With a bit of practice much faster and use other fonts. You can use presspull to change height. BUT SET TEXT HEIGHT CORRECT BEFORE EXTRUDE. Oh yeah why do you have units set to Architectural when your talking mm ? new block.dwg2 points
-
Ok I used Txtexp on "MACEY", then went to a 3d view so could see what was going on VPOINT -1,-1,-1. You have to check that all the objects that appear are plines I had to join the little "A" triangle. Ok extruded the base 1.5 Extruded the circles 2.5, then unionid both, to base, subtracted the inner circle from the new solid. Extruded the ""M" 4.5 then did a union again. Extruded the two parts of the "A" unioned together with base then subtracted the inner triangle, You can see the progress. What you want is not a single step but rather multiple steps, lastly can export the STL file. Once you get the hang of extruding, subtrcat and union you can do multiple objects at one time. This is a bit rough as a solid and can be done better, by moving the text to a Z matching base height before you start.2 points
-
PETA-INSERT ELEVATIONS FROM TEXTS INSIDE THE CLOSED OR OPEN POLYINE.LSP Try this one too2 points
-
The equal linetype as supplied is just a dashed linetype that has a length of one unit and a gap of one unit. By setting its LTSCALE to the length of a pipe you can get an idea of the number of pipes involved. I have somewhere also convert an existing line to two lines as per right hand image, The GIS used to dump out a single line on a size layer so we wanted 2 dashed lines to imply existing drainage. Will try to find I think that is what you want.2 points
-
Incremental Numbering Suite Version 4.0 Released. The main feature of the new version is the introduction of a dedicated 'Content Builder' to facilitate the construction of an incrementing string from an arbitrary number of incrementing and/or static components. With this feature, the user now has the ability to independently control the increment amount and increment frequency for each component of the string, enabling multiple sections of the string to increment by different amounts and at different rates to one another. The new version also introduces the ability to load & save application configurations, streamlining the operation of the program for multiple numbering systems.2 points
-
2 points
-
Posts are one thing, but what about the actual traffic? Like I stated, most fora already have the answers to questions, so often no need to interact and make a post. CADTutor shows most online 9,928 April 2nd 2026, which was probably a lot of AI bots, etc.1 point
-
Perhaps you could use the undocumented (acet-sys-shift-down) express tools function within the grread loop? Then you would have to manipulate highlighting with (redraw [3/4]) and use (ssadd) and (ssdel) to update the selection set.1 point
-
Isn't that how CAD works already? you select something either by mouse clicke or window it will be highlighted hold shift to deselect it the same way. I know if you have to many things selected they are no longer highlighted.1 point
-
I think you would need to test for 'shift' being pressed and the test for a left mouse entity selection. Do a 'princ' on your grread loop to display what you are doing, shift and select something - which should give you what you want to test for.1 point
-
I wondered the same.1 point
-
Sample drawing with correct layers and what your looking for? For mtext update the entmake with the following. 71 is the text justification defaulting to mid center. use \n for next line. (defun rh:em_mtxt (pt txt lyr ang hgt) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 8 lyr) (cons 50 ang) (cons 7 (getvar 'TEXTSTYLE)) (cons 1 txt) (cons 10 pt) (cons 40 hgt) (cons 50 ang) '(71 . 5) ) ) ) (rh:em_mtxt '(0 0 0) "hello\nthere" "0" 0 0.5) rh:2azimuth can be replace with (angtos l_ang 1 5)1 point
-
I'm not sure if zoom object will work in all cases. I tried several shapes including the OP's drawing and sometimes I was zoomed more than the zoom object showed, maybe zoom object and then zoom some more. I personally believe the better option would be to just use BricsCAD as it seems to handle these situations better. I would be curious to know the method they use for pick points for Boundary and Hatch in BricsCAD and if it works correctly in all cases. As discussed, select objects for hatch seems to be the best option for difficult geometry over pick points. It might be an easier code, though IIRC there should be some good codes out there for creating a closed polyline, then making regions so should be easier than working from scratch.1 point
-
If your offering something a good idea is to provide images or a movie about what the program does, else the "Why bother" will occur. "(setq oldDynPrompt (getvar "DYNPROMPT")) Fails in Bricscad V25. Here is a freebie for you I dont uses initget. Multi radio buttons.lsp (if (not AH:Butts)(load "Multi radio buttons.lsp")) (setq ans (ah:butts but "V" '("Please choose" "1-Polylines" "2-Lines" "3-Arcs" "4-Circles" "5-Splines" "6-FeatureLines" "7-All"))) You ask for a distance only so it would make sense that it ask for intervals, we did road design and in an intersection kerb the curve was nearly always based on 4 points. maybe when asked for a distance enter a -ve value say -4 means break into 4 even spacing. Have added a couple of other make dcl on the fly for you just leave my name in the code but free to use. You can make a dcl then convert it to lsp code using write-line for the dcl code so dont need the MULTI's.Multi GETVALS.lspMulti toggles.lsp1 point
-
The only "solution" besides zooming in I could determine, was to copy the polylines in place and use region on them, which seems to be correct in the example drawing. That should be able to be done with a LISP? Boundary.dwg1 point
-
I use windows terminal winget upgrade. the publisher has to send them the file i think how it works. it directs to the url submitted.1 point
-
Thanks both for the honest feedback — exactly what I was hoping for. @pkenewell — appreciate the link, I'm aware of Lee Mac's MPLine and have a lot of respect for his work. His implementation is elegant and handles the core offset drawing well. MultiPLine goes in a different direction: DCL-based configuration dialog, per-line layer assignment, named presets that persist across drawings, and the Pro version adds a command reactor for auto-sync. Different scope rather than a direct replacement for what he built. Worth knowing about either way so thanks for flagging it. @BIGAL — fair points across the board. BricsCAD: honestly didn't design for it and can't make promises there. The reactor implementation in Pro leans on AutoCAD-specific VLR functions. Lite might load fine in BricsCAD but I haven't tested it — if any BricsCAD users try it I'd be curious to hear the result. On the "why pay" question: fair challenge. The free Lite version covers the core workflow for most users. The Pro is aimed at teams and daily-driver users who want auto-sync and a preset library they can share across a team. Whether that's worth $29 is genuinely up to the buyer — I'm not trying to oversell it. The package suggestion is actually something I've been thinking about. MultiPLine is my first commercial release but I have other tools in progress. A bundle makes more sense as a value proposition and I'll keep that in mind for when there's more to package together. One more thing — I've added the full .lsp source to the Lite download on Gumroad. Free to inspect, modify for personal use, and learn from. Thanks again for taking the time — this kind of feedback from experienced users is more useful than any marketing. Zlatislav1 point
-
Bit late to the party but try this. See the header for changes I've made. (vl-load-com) ;; ;; Replace multiple instances of selected blocks (can be different) with selected block ;; Size and Rotation will be taken from original block and original will be deleted ;; Required subroutines: AT:GetSel ;; Alan J. Thompson, 2010.09.02 ;; Found at: http://www.cadtutor.net/forum/showthread.php?48458-Replace-Selected-Block-Or-Blocks-With-Another-Block ;; ;; EDIT by 3dwannab, 2018.04.09 - Added redraw to old block selection, Error handling for redraw and sssetfirst newly created blocks. ;; EDIT by 3dwannab, 2024.08.15 - Removed original selection from the new selection set and output block name to commandline. ;; EDIT by 3dwannab, 2024.11.28 - Give the user the ability to replace the same blocks by name as the ones selected. Option Yes/No. ;; - Option to choose whether you want to match properties or not. Option Yes/No. ;; - Added undo handling. ;; - Changed the redraw to a regen to correctly display the new selection of blocks. ;; ;; TO DO LIST ;; N/A ;; (defun c:BKReplace (/ *error* acDoc ansMatchProps ansReplaceAll blkNew blkNewObj def e f lst ssReplaced ssSel ssVla var_cmdecho var_osmode var_selectsimilarmode) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (command "_.regen") (setvar 'cmdecho var_cmdecho) (setvar 'osmode var_osmode) (setvar 'selectsimilarmode var_selectsimilarmode) ) ;; Start the undo mark here (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) ;; Get any system variables here (setq var_cmdecho (getvar "cmdecho")) (setq var_osmode (getvar "osmode")) (setq var_selectsimilarmode (getvar 'selectsimilarmode)) (setvar 'cmdecho 0) (setvar 'osmode 0) (if (and (AT:GetSel entsel "\nSelect NEW block: " (lambda (blkOriginal / e) (if (and (eq "INSERT" (cdr (assoc 0 (setq e (entget (car blkOriginal)))))) (/= 4 (logand (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 e))))) 4)) (/= 4 (logand (cdr (assoc 70 (entget (tblobjname "LAYER" (cdr (assoc 8 e)))))) 4)) ) (setq blkNewObj (vlax-ename->vla-object (car blkOriginal))) ) ) ) (not (redraw (vlax-vla-object->ename blkNewObj) 3)) ) (progn ;; initget from LeeMac help pages (initget "No Yes") (setq ansReplaceAll (cond ((getkword (strcat "\nReplace all the same blocks as the one you select now ? [Yes/No] <" (setq ansReplaceAll (cond (ansReplaceAll) ("Yes"))) ">: " ) ) ) (ansReplaceAll) ) ) ;; If No to replace blocks only replace the selection (if (= ansReplaceAll "No") (progn (princ "\nSelect OLD blocks to be replaced: ") (setq ssReplaced (ssget "_:L" '((0 . "INSERT")))) ) ;; If yes, replace the same blocks as the one you select (progn ; Code by Lee Mac http://www.cadtutor.net/forum/showthread.php?92638-Simple-fix-%28LISP-noob%29-Syntax-problem&p=633824&viewfull=1#post633824 ;; Iterate over the block table and compile a list of xref blocks to exclude (while (setq def (tblnext "block" (not def))) (if (= 4 (logand 4 (cdr (assoc 70 def)))) (setq lst (vl-list* "," (cdr (assoc 2 def)) lst)) ) ) ;; Attempt to retrieve a selection of blocks (but not xrefs) (setq ssReplaced (ssget (cons '(0 . "INSERT") (if lst (vl-list* '(-4 . "<NOT") (cons 2 (apply 'strcat (cdr lst))) '((-4 . "NOT>"))))))) ;; Set selectsimilarmode to use the name of an object. (setvar 'selectsimilarmode 128) ;; If ss1 one is valid then do this (if ssReplaced (progn (vl-cmdf "_.selectsimilar" ssReplaced "") (setq ssReplaced nil) ;; Reset the selection set (setq ssReplaced (ssget)) ;; Create a new selection set for to zoom and reselect as the zoom objects will do this ) (princ "\n: ------------------------------\n\t\t*** Nothing selected ***\n: ------------------------------\n") ) ) ) (setq f (not (vla-startundomark (cond (acDoc) ((setq acDoc (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) ) ;; initget from LeeMac help pages (initget "No Yes") (setq ansMatchProps (cond ((getkword (strcat "\nMatch these properties? Insertionpoint, Rotation, XEffectiveScaleFactor, YEffectiveScaleFactor & ZEffectiveScaleFactor\nNo only matches the Insertion Point and Rotation[Yes/No] <" (setq ansMatchProps (cond (ansMatchProps) ("Yes"))) ">: " ) ) ) (ansMatchProps) ) ) ; Set ssSel to a null selection set: (setq ssSel (ssadd)) (vlax-for blkOriginal (setq ssVla (vla-get-activeselectionset acDoc)) ;; Check if old block is not part of the new selection (if (not (equal (vlax-vla-object->ename blkNewObj) (vlax-vla-object->ename blkOriginal))) (progn (setq blkNew (vla-copy blkNewObj)) (cond ((= "Yes" ansMatchProps) (mapcar (function (lambda (p) (vl-catch-all-apply (function vlax-put-property) (list blkNew p (vlax-get-property blkOriginal p)) ) ) ) '(Insertionpoint Rotation XEffectiveScaleFactor YEffectiveScaleFactor ZEffectiveScaleFactor) ) ) ((= "No" ansMatchProps) ;; Only match the insertion point (mapcar (function (lambda (p) (vl-catch-all-apply (function vlax-put-property) (list blkNew p (vlax-get-property blkOriginal p)) ) ) ) '(Insertionpoint Rotation) ) ) ) ; The following command adds the blkNew entity to the selection set referenced by ss2: (ssadd (vlax-vla-object->ename blkNew) ssSel) (vla-delete blkOriginal) ) ) ) ; Select ssSel (sssetfirst nil ssSel) (redraw (vlax-vla-object->ename blkNewObj) 4) (vla-delete ssVla) (princ (strcat "\n'" (vla-get-effectivename blkNewObj) "' has replaced " (itoa (sslength ssReplaced)) (if (> (sslength ssReplaced) 1) " blocks" " block"))) ) ) (vla-EndUndoMark acDoc) (*error* nil) (princ) ) (defun AT:GetSel (meth msg fnc / ent good) ;; meth - selection method (entsel, nentsel, nentselp) ;; msg - message to display (nil for default) ;; fnc - optional function to apply to selected object ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (blkOriginal) (eq (cdr (assoc 0 (entget (car blkOriginal)))) "ARC"))) ;; Alan J. Thompson, 05.25.10 (setvar 'errno 0) (while (not good) (setq ent (meth (cond (msg) ("\nSelect OLD blocks to be replaced: ") ) ) ) (cond ((vl-consp ent) (setq good (cond ((or (not fnc) (fnc ent)) ent) ((prompt "\nInvalid object!")) ) ) ) ((eq (type ent) 'STR) (setq good ent)) ((setq good (eq 52 (getvar 'errno))) nil) ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again."))) ) ) ) (princ "\nBK_Replace.lsp loaded...") (princ) ; (c:BKReplace) ;; Unblock for testing1 point
-
Consider the following example - the selection could be automated if the target block/attribute tag is known, or alternatively, it could search every block attribute for the target field expression and perform a replacement: (defun c:test ( / e n x ) (setq n "$(substr,$(getvar,dwgname),1,3)") (while (progn (setvar 'errno 0) (setq e (car (nentsel "\nSelect field: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null e) nil ) ( (not (wcmatch (cdr (assoc 0 (setq x (entget e)))) "TEXT,MTEXT,ATTRIB,MULTILEADER,*DIMENSION")) (princ "\nInvalid object selected.") ) ( (not (and (setq x (cdr (assoc 360 x))) (setq x (dictsearch x "ACAD_FIELD")) (setq x (dictsearch (cdr (assoc -1 x)) "TEXT")) (setq x (cdr (assoc 360 x))) (setq x (entget x)) (= "FIELD" (cdr (assoc 0 x))) (= "AcDiesel" (cdr (assoc 1 x))) ) ) (princ "\nThe selected object does not contain a DIESEL field expression.") ) ( (entmod (subst (cons 2 (strcat "\\AcDiesel " n)) (assoc 2 x) (subst (cons 1 n) (assoc 1 (member (assoc 6 x) x)) x) ) ) (command "_.regenall") ) ) ) ) (princ) )1 point
