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 1 Quote
Javier Longa Posted 6 hours ago Author Posted 6 hours ago 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 55 minutes ago Posted 55 minutes 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
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.