Javier Longa Posted Thursday at 12:42 PM Posted Thursday at 12:42 PM Hello. I'm happy to share this routine I created with the help of Copilot, which I believe works acceptably for distributing elements (sprinklers, detectors, etc.) based on user input. I would be very grateful if any member of this forum could improve the code or offer any advice. I'm a big fan of @Lee Mac's programs, whom I consider a master. The routine will ask the user to define the measurements that define minimum and maximum values and then, by selecting a block, from which it acquires the layer and scale properties, by selecting an area, with or without "islands", it will generate a mesh pattern, which for a preliminary design is acceptable or approximate in many cases. I am Spanish and the routine is coded in Castilian Spanish (Spain). PCI_PRO (PFP).lsp 2 1 2 Quote
CamDuy Posted Thursday at 03:15 PM Posted Thursday at 03:15 PM Very well, the community needs people like you. 1 Quote
BIGAL Posted Thursday at 11:42 PM Posted Thursday at 11:42 PM (edited) Welome aboard. A couple of suggestions. Google translate is your friend, you can convert Spanish to English so make a English version. Code picks a control point that the grid/blocks is based off, rather than just lower left. Can do answers based on a rotated axis. may have a side on angle as control line. Hint Array & UCS The get pline points you can use this, much shorter than your code. ; thanks to Lee-mac for this get points (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent)))) Not sure if extra block outside shape should be there shown in image Yes did something similar in the 1980's. Looks at what is outside of shape and erase. The dcl input is a good idea. Happy to discuss maybe a easier way to make sure erase all objects outside shape. Edited Thursday at 11:44 PM by BIGAL Quote
indiancad Posted Friday at 06:13 AM Posted Friday at 06:13 AM Nice work! For a preliminary sprinkler/detector layout, this looks very practical, especially considering it handles irregular boundaries and islands. The idea of inheriting the selected block's layer and scale is a smart touch—it saves a lot of manual cleanup. One suggestion would be to add an option to rotate the grid based on a user-defined angle or a reference line, since many buildings aren't aligned with the UCS. It might also be useful to preview the calculated grid before inserting the blocks, giving the user a chance to adjust spacing. Great project overall, and thanks for sharing it with the community. I'm sure many fire protection designers will find it useful. Quote
Javier Longa Posted Friday at 07:23 AM Author Posted Friday at 07:23 AM Of course, I appreciate any observations like the ones you mentioned in your post, @BIGAL, but I'm sorry to say I can't have a conversation about programming since I have no programming knowledge whatsoever. I would only ask that if you deem it appropriate to modify the code by adding considerations such as ensuring the routine can work in any SCP, or drastically shortening overly long code, or any other relevant element I may have overlooked, I would be very grateful. Quote
SLW210 Posted Friday at 10:51 AM Posted Friday at 10:51 AM Does this follow a standard like NFPA? Quote
BIGAL Posted Saturday at 01:19 AM Posted Saturday at 01:19 AM (edited) @indiancad @Javier Longa there may be a way of using Array if a new UCS OB is used to orient the grid. In the changed rotation need to rotate the block as well. A question @Javier Longa " since I have no programming knowledge whatsoever" then how did you come by the code ? It is considered good manners to acknowledge who wrote the code, if known, or mention Author unknown. Edited Saturday at 01:19 AM by BIGAL 2 Quote
Javier Longa Posted yesterday at 06:32 AM Author Posted yesterday at 06:32 AM I apologize @BIGAL, because I don't think I explained myself well. The code was generated entirely by COPILOT, Microsoft's AI, following the instructions I gave it. If there had been a previous author in this case, I would have mentioned it, just as I've confessed that I'm a huge fan of @Lee Mac's work. And I don't think I made it clear that if any member of this group, expert or not, feels like improving this code, I'll be very grateful, as it's code that could be very useful in my profession. I'll try to add the necessary code to account for the UCS rotation (Array if a new UCS OB). Replying to @SLW210, I think the simplicity of the code lies in the fact that it can use NFPA values as well as FM Global or UNE EN 12845 values, since it only requires adding distances. 1 Quote
SLW210 Posted 19 hours ago Posted 19 hours ago Just trying to help you improve your LISP programming, so don't take this as not appreciating what you have done. These suggestions just make it better for everyone and should be doable upgrades, IMO. I would have to know those values in advance. I am sure some people do this everyday and may memorize them, but that is a bad habit to get into. 1. The specifications can change. 2. Some may need to use different standards each project. 3. Some people might mis-remember the values, etc. leading to errors. Programs that deal with a Standard should always employ the standard if possible, even if you make it just for the one you use. For example: Al's Steel Mill and Wisey's, they each employ a different standard for steel shapes and do so with easily updateable files. Here is a thread here on Al's with an updated standards file. Updated AISC Shapes for STL.LSP - AutoLISP, Visual LISP & DCL - AutoCAD Forums There is on CADTutor and maybe some other fora, etc. some programs dealing with piping, they each work towards the respective standards in those industries. ANSI B16.5 Flanges Lisp - AutoLISP, Visual LISP & DCL - AutoCAD Forums There are a few more, but speaking of those flanges, etc. I or someone needs to see if any of those standards have changed since it's been a while. Also, another question, since I rarely have to do sprinklers, etc. that often, does this work with AutoCAD MEP's sprinklers? I'll have to check, but I do not believe they are actual blocks, so that could be another upgrade suggestion. Quote
Javier Longa Posted 17 hours ago Author Posted 17 hours ago I appreciate those suggestions, of course, but due to my age and the demands of my job, I find it very difficult to learn any kind of programming. I'll continue using Copilot. Regarding what you mentioned @SLW210 about the regulatory values, I don't see any reason to change them. When I created the routine, it was to help my colleagues who are familiar with the values they need to apply, not in a fixed way, but by verifying their validity against the applicable standard. I didn't create the routine for someone unfamiliar with the different fire safety regulations. I've uploaded this application, and I'm repeating myself a lot, sorry, because I don't think I could find anything similar already created by others that was free, and even the existing ones, including those in calculation software, aren't reliable. I also wanted to ask a programming expert to take up the challenge and collaborate on improving it. Following up on this last comment, I'm going to upload a new version that corrects the design when there's a rotation in the UCS, modifies the polyline selection code using Lee Mac's code (thanks to @BIGAL and @Lee Mac), and also includes other considerations. Please excuse me if it's still in Spanish, but as I said, it's primarily for my team's use. PCI_PRO (PFP)_V3_8.lsp Quote
BIGAL Posted 7 hours ago Posted 7 hours ago In the multi getvals.lsp you can preset a value for say the spacing, or even have 2 values for row & column Min max preset. Just add more to the dcl example. Look at the last "1" change it to say '2.4", it must be a string not a number. That way you can come up with a spacing that meets min max criteria. (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Enter values " "Row spacing " 5 4 "2.4" "Col spacing " 5 4 "2.4" ))) Multi GETVALS.lsp In the code it uses the lower left as control, but you can find closest vertice to where you picked the pline outline. Then you can set the control of where the spacing starts from. I use a over draft to cover the entire area with sprinklers then erase those out side of the boundary. Even worked for plines with curves.. I think you will struggle with Copilot as you get more complex with extra features, now is a good time to learn programming. Reading code and getting an understanding of what it is doing and you will soon write your own. Plenty out there to help. Lastly did you google Fire sprinklers autocad lisp" ? The topic has been answered before answers may be at "Forums/Autodesk" aka Autocad. Quote
Javier Longa Posted 47 minutes ago Author Posted 47 minutes ago Thanks for the advice and the routine. The routine might be useful for spacing elements, but my code generates a distribution based on coverage, taking into account various parameters. Regarding Copilot falling short, I agree, although I don't think I'll continue working on this routine with this AI, at least not yet. And I should mention that I've created other routines, also with Copilot, which is the only AI I have available. I'm also the author of many dynamic and parametric blocks related to fire protection systems. As for learning to program, as I said before, I'm 60 years old and I don't have much time left before retirement. I don't see it as being productive. Maybe as a hobby. And yes, I've searched for the topic "AutoCAD Lisp Sprinklers" many times and I've never found anything that seems useful and is offered for free. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.