Clint Posted May 8 Posted May 8 Given: Platform: BricsCAD 22 (to current version) File format: 2018 .DWG Units: Inch-based Content: Model space drawing title borders and 1:1 design content Sheet sizes used: ANSI A Portrait (8-1/2" x 11") ANSI B Landscape (11" x 17") ANSI D Landscape (22 x 34") Special conditions: NO BLOCKS - No block definitions (related: no block attributes) of title borders. LAYER-SPECIFIC BORDERS - Border frames are polylines on a drawing border layer. SHEET SIZE MIX - One file contains the standard sheet sizes referred in the "Sheet sizes used" section above. Find: Strategies are needed to process multiple drawings (that include drawing border and design content are in model space) at various sheet sizes using Visual LISP to include a dialog box TWO GOALS GOAL ONE - SAVE FILE OPTIONS Save each of the multiple drawings as an individual file: Output File format options include: .DWG .R11/12 ASCII DXF .PDF GOAL TWO - PLOT FROM FILE Plot each of the multiple drawings to a printer. Thoughts and Questions My thought is that this will be my first complete program. As a novice LISP programmer, my research starts here and will continue First Objective Programmatically selecting drawing borders Your thoughts are welcome!!! FYI: I have a hardcopy of the LISP reference book by Rawls and Hagen and sample files from aged course work. Thanks, Clint Quote
Steven P Posted May 8 Posted May 8 Do you need to plot from model space? I find it far easier to plot from paperspace, can set up a new tab for each plot from a single drawing. The benefits of this is that a single method can be used for almost every drawing rather than having the LISP calculate drawing extents and so on. In a batch routine assume no user interface, which means the model space has to be a fixed location for the plot to work without a lot of extra coding. I am not sure what you are drawing but imagine building layout, even a small 5x10m, 15'x30' building - that is a very large piece of paper drawn at 1:1 scaling plotted from model space. So I'd recommend setting each drawing up to plot from model space. Will you have added the borders as a part of the drafting process or will you want the LISP to do that, remembering that no user interaction, the LISP rules will need to work out what is the drawing and what is working sketches within the drawing file. Might be better to add the borders manually as a part of drawing. You could use a LISP to grab and insert the borders - in fact if the borders are not blocks, LISP could just draw them, say a command like "InsertANSIA", "InsertANSIB" and so on to add a border. Working out if model space / paper space is the best solution for you is the first step. The next step is to create a LISPs that will work on a single drawing - in a batch you just loop open the next drawing and then work those LISP on it, save, close, open the next one. A good first step for actually producing a LISP would be the book or an online guide such as you might find from Lee Macs website. Quote
Clint Posted May 8 Author Posted May 8 Hi Steven P., I appreciate your wealth of comments. Perhaps the following points may better illustrate the constraints that I face and why this path has been chosen. CURRENT USER AUDIENCE Starting at a company where most users are very experienced within the industry. Some have worked since the board drafting era. The advantages in the tools of DWG-based applications that I have set up at other companies in other industries have never been utilized. This includes layout usage. LAYOUT ADVANTAGES CONFIRMED I set up and leveraged the advantages of the layout (formerly paper space) in AutoCAD that were adopted into my past employer's design department workflow since its inception. I believe that was in or around 2000 - if I am not mistaken. I am a fan of layouts! DRAWING ORGANIZATION - CURRENT SITUATION With all the above in mind, I turn to our typical multi-drawing, model space-based CAD file. So, for storing our detail drawing collections, we utilize a single CAD file for each collection. Each collection contains detail drawings that are arranged by topic and grouped into rows with as many as fifty detail drawings in each row. INTENDED DRAWING USE Ultimately, these detail drawings are used by another specialized design software only. These drawings are not intended for use outside of this design software. The software has specific file format and content limitations. Limitations include: Each detail drawing is saved as an ASCII DXF file. All elements are migrated to layer zero while maintaining object-specific properties (automation was applied here as developed by a CAD forum member ). AUTOMATION GOALS To streamline the exporting of each detail drawing into an individual file in either DXF, DWG , or PDF file format. INITIAL OBJECTIVE To determine what type of data such as layer-based and/or polygonal drawing frame sizes that can be leveraged in order for the program to select each of the detail drawings by row. Thanks, Clint 1 Quote
BIGAL Posted May 9 Posted May 9 Using layouts is the way to go you can automate their creation in many ways, as it sounds like you have multiple objects in MODEL that need to be plotted on a single sheet. A simple approach using a single company title block of fixed size, the obvious is getting the mview to match an area of model at correct scale. So why not enter desired scale then pick approx center point, hey all done. Its not that hard to show that to others, the next part of this is plot layouts setup for your company standards. 1 Quote
Clint Posted May 9 Author Posted May 9 Hi BIGAL, Indeed it is VERY tempting to have others advance to layouts. I appreciate you providing an example of how easy it could be! As a industry newbie, I am on the support side of things and it is supplementary to my main role outside of CAD. I am introducing basic customization along with helping out with detail drawing edits and conversions. My personal aim is to export each detail drawing residing in a multi-drawing file. Picture 250+ drawings each manually exported as is the case right now. The exported drawing become either: An R11/12 DXF ASCII file for compatibility with our main design software or, ... A PDF file for a detail drawing standard catalog. For others who do production work, Ours is a very unique workflow in this niche industry. All of the work and all of the users - regardless of age - have been groomed to and are now working in 95%+ 2D and model space. For the detailers, the focus is on providing informal drawings to be used as details of steel building connections that our otherwise very powerful and multi-faceted main design application cannot now construct. Plus, experienced detailers 30 -50 years of experience along with a few with 5 - 20 years of experience are mostly set in their way of doing things. I will push for layout usage in demos. I am a fan! I have two layout-based LISPs that will really help as they have me. These LISPS (by others) include: LISP 1. A viewport transfer program that exports the viewport frame to model space. LISP 2. A viewport scaling tool can define the viewport scale and also defines the viewport center point. Used together, both LISPs really "saves your bum" when you forget to lock the viewport - re-centering and scaling based on the exported model viewport frame! Thanks again, Clint Quote
Steven P Posted May 9 Posted May 9 OK, so it might be a bit of a push to change things over, but it is possible if you can show that it will be quicker for them (ie... they can grab a cup of tea in the time it would have taken). On the existing drawings, are all the sheets in set positions in model space or does that vary? Are you able to post a sample, maybe with details removed as necessary, to show how they are currently laid out. Quote
Clint Posted May 9 Author Posted May 9 (edited) Steven P., I have included a screenshot. As you will see, the drawings are in rows. I appreciate your continued concern, suggestions, and time. Clint Edited May 9 by Clint Quote
CyberAngel Posted May 9 Posted May 9 If you have to do this old school, you might as well use old school tools. In Land Desktop, they create invisible blocks for each profile. You could place a block at each detail's "insertion point" (which gets around the restriction on title blocks); define invisible attributes in the blocks for name, size/scale, and other parameters; and use your function to find and process each group of details. Advantages: You can select the blocks by name, layer, size, or other criteria. Once you have the location and the size of a detail, you can select the objects that belong to it. Once you select a detail's contents, you can export them to the proper format--or do whatever else you want with them. Disadvantages: Someone has to make sure the blocks get created properly and stay synced to the details. If you go the layout route (highly recommended), you can keep the viewport frame and the viewport in paper space, while you concentrate on the detail itself in model space. The disadvantage here is staying synchronized (again). Advantages: You can define a view in model space and snap to it as necessary. You can process multiple layouts with a single command; schemes include shift-select for a series of layouts and the Sheet Set Manager. You can avoid clutter in model space by placing notes, dimensions, etc. in paper space. You can use the ExportLayout command to create a separate file (DXF is an option), which you can then process as needed. Quote
Clint Posted May 9 Author Posted May 9 (edited) Hi CyberAngel, This is some serious food for thought even if considered "old school" compared to the benefits of the wonderful layout paradigm! I understand the importance of coordination and the necessity of performing file maintenance. The most difficult in choosing the path forward from your options. Of course, for fans like you and me, the route to take is the smooth one: The "highly recommended" layout option. Since all here but a handful are untrained and uncomfortable with layouts, the caveat is that all related drawing content would reside in model space in this initial effort. Next, the specter of growing my LISP programming skills is the elephant in this room. The concept of figuratively eating an elephant applies: One bite at a time. (If I did eat one, I would prefer it served well done.) Thanks for your well-communicated suggestions! Clint Edited May 9 by Clint Quote
Steven P Posted May 9 Posted May 9 So the borders have a polyline perimeter and on their own layer. Looking at the screen shot these borders are inserted in the drawing. If you use ssget and filter it by layer and by polyline that should only pick up items in the border. If you loop through this selection set and remove any polylines that are not 39", 56" or 112" (the sheet perimeter length) that should give you a selection set of all the sheets and in rectangles will define the locations? Assuming here that for example a 112" sheet doesn't contain a line in it say 39" long. Could also filter again for polylines with 4 verticies and perhaps orthogonal edges. Would that work as a start? Quote
Clint Posted May 9 Author Posted May 9 Steven P., Your proposed selection strategy appears to be solidly based. What are a few of the the key LISP (focusing on Visual LISP) concepts and commands that I would need to master to facilitate this effort? Advantages: As I understand it now, this method would process drawings as they appear. There would be no need for constant content comparisons. Although communication is not an issue, this method would reduce reliance on word of mouth and memory to manage content. Again, I must advance my Visual LISP coding skills to make this automation a reality. I appreciate your time so far. Thanks, Clint Quote
BIGAL Posted May 10 Posted May 10 (edited) Like others YES can plot all fixed size objects in one go as per image, the main thing is you have a title block then can find all of them and plot them. You can EDIT attached and give it a try, the order of plots will be based on creation order but there are ways around that also. Adding a sort on X & Y position of title block. A good advanced plot software is also out there does way more than this, I had a brain blank getting Author's name but he logs in here so will hopefully answer. Revers ? Let us know if works else post a dwg. Plot-titles-in-model.lsp Edited May 10 by BIGAL Quote
exceed Posted May 10 Posted May 10 This is not my code, but it may be helpful for batch pdf in model space. A block is required for selection, but rather than using other functions of the block, it uses a bounding box, so all you have to do is surround the entire area with a rectangle and then change the condition to a polyline. 1. Draw a large rectangle encompassing the entire area. 2. With the option without an island, select an empty space and create a hatch. 3. You can get the outline with hatchgenerateboundary in specific layer. you can create a variable that selects paper according to the rectangle size ratio. to save as, use wblock in that rectangle selection set. Quote
Clint Posted May 10 Author Posted May 10 10 hours ago, BIGAL said: Like others YES can plot all fixed size objects in one go as per image, the main thing is you have a title block then can find all of them and plot them. You can EDIT attached and give it a try, the order of plots will be based on creation order but there are ways around that also. Adding a sort on X & Y position of title block. A good advanced plot software is also out there does way more than this, I had a brain blank getting Author's name but he logs in here so will hopefully answer. Revers ? Let us know if works else post a dwg. Plot-titles-in-model.lsp 1.06 kB · 48 downloads Hey BIGAL, Many thanks for the LISP programs! It appears that you understand my goal. A bit of tweaking will be needed to accommodate our awkward, inch-based "world" (border dimensions) Another interesting issue is that blocks are not used for drawing borders (a bit different to me). I will create them and create an array of various sizes to test your program. At this point, it may be later next week. QUESTION Is there an alternate method that selects what to plot based on sets of polyline dimensions that represents drawing borders? About Revers: I found the product link - https://www.kdmsoft.net/revers.html by Dmitrii Kirillov. So, there ya go... I reviewed the video on this application. It was my feeling at that time that it was a bit too much (if that's possible) for our needs. To be fair, I had very little time to invest at that point. In fact, I just downloaded it and will give it a proper go in trial mode. LISP rules! Thanks again to you and all who are following and contributing to this post. Clint Quote
Clint Posted May 10 Author Posted May 10 Batch plotting is valued but is a secondary goal at the moment. The main goal is to automate the EXPORT of a multiple detail drawing collection to their own DXF file. The SOURCE DWG FILE collection consists of over 200 detail drawings arranged by rows. The selection will be based on a rectangular polyline that forms the border of each drawing in three size variations (loosely based on ANSI standard sheet sizes A, B, and C) The lower left corner of the drawing frame will be located at the World UCS coordinates X,Y,Z = zero in each EXPORTED DXF file. Quote
BIGAL Posted May 11 Posted May 11 (edited) "plot based on sets of polyline " if the outer most or a single pline box is around each PLOT Area then can use that instead of a block but it would need to be on a single layer so you can get all those plines only. Post a dwg would best so can look at the Defacto Title. May be something in it that can be used. DXF PDF 17x11 all can be outputted but must have a reference box. When you add a box in future make sure it meets the required criteria. Do have a lisp to do that now ? Edited May 11 by BIGAL Quote
Steven P Posted May 13 Posted May 13 (edited) I reckon this is mostly there to give you the borders coordinates given outline of the border is a polyline and the length of it is the sum of the paper dimensions above. it might need some adjustments to suit your case. The coordinates are listed in BordersCoords at the end, function name Test (defun c:test ( / MySS MyPoly MyEnt MyPolyLength PtsList LL1 LL2 UR1 UR2 BordersCoords) (vl-load-com) (defun curvelength ( ent / )(vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))) ;; Lee Mac Suggestion (defun LM:MAssoc ( key lst / pair return ) ; Get 'key' values from dotted pair lists (while (setq pair (assoc key lst)) (setq return (cons (cdr pair) return) lst (cdr (member pair lst))) ) (reverse return) ) (setq MySS (ssget '((0 . "LWPOLYLINE") (-4 . "<OR") (90 . 4) (90 . 5) (-4 . "OR>")))) ; 4 or 5 points polylines (setq acount 0) ; A counter (while (< acount (sslength MySS)) ; Loop through Selection set MySS (setq MyPoly (ssname MySS acount)) ; nth item in MySS entity name (setq MyEnt (entget MyPoly)) ; nth item in MySS entity description (setq MyPolyLength (curvelength MyPoly)) ; Length of the polyline (setq fortytwomax 0) (foreach n (lm:MAssoc 42 MyEnt) (setq fortytwomax (max (abs n) fortytwomax))) ;Get maximum Polyline segment arc radius (if (and ; If: (or ; Poplyline is closed rectangle: (equal (assoc 10 MyEnt) (assoc 10 (reverse MyEnt)) 0.05 ) ; start / end point equal +/- 0.05 (equal (assoc 70 MyEnt) '(70 . 1)) ; 'closed' polyline ) ; endor (= 0 fortytwomax) ; Max segment radius 0: Straight lines only (or ; And polyline Length is border length (equal MyPolyLength 39 0.4) ; +/- 10% (equal MyPolyLength 56 0.6) ; +/- 10% (equal MyPolyLength 112 1.15) ; +/- 10% ) ) ; end and (progn (setq PtsList (lm:MAssoc 10 MyEnt)) ; Get list of polyline points (setq LL1 (car (car PtsList)))(setq LL2 (cadr (car PtsList))) ; Work out lower left / upper right coordinates (setq UR1 (car (car PtsList)))(setq UR2 (cadr (car PtsList))) (foreach n PtsList (setq LL1 (min (car n) LL1)) (setq LL2 (min (cadr n) LL2)) (setq UR1 (max (car n) UR1)) (setq UR2 (max (cadr n) UR2)) ) (setq BordersCoords (cons (list (list LL1 LL2) (list UR1 UR2)) BordersCoords)) ; make list of all border coordiantes (redraw MyPoly 3) ; remove this line if happy with selection ) ;end progn ) ; end if (setq acount (+ acount 1)) ) (princ (length BordersCoords)) (princ " Borders Found. ") (getstring "\nHit Enter to remove highlights") ; remove this line if happy with selection (command "regen") ; remove this line if happy with selection (princ "Border Coordinates: ")(princ BordersCoords) (princ) ) Edit: Added a check that selected polylines are straight (no arcs in the segments) Edited May 13 by Steven P Quote
Clint Posted May 13 Author Posted May 13 Steven P, As with all high quality code, the comments really help! Testing will commence this week. Your code submission will also go a long way to help in my continuing study of Visual LISP. My current, basic level of understanding of the LISP language (mostly AutoLISP) includes the purpose of the car, cadr, etc., in extracting values from lists. The Visual LISP will need much more attention from me. I feel that this is where yours and others code offerings based on a specific objective / request really help! Thanks, Clint 1 Quote
Steven P Posted May 13 Posted May 13 When you look through the code, ask away - it is always nice to see someone taking the time to look at the suggestions. Quote
Steven P Posted May 13 Posted May 13 (edited) Another slight update the report at the end should give a list with 4 details per plot Paper Size, Orientation, LL Coord, UR Coord Limitation is going to be in the larger plot sizes if there is a polyline the same length as a smaller paper size with 4 verticies and closed at the end not sure if that will ever be an issue? (defun c:test ( / MySS MyPoly MyEnt MyPolyLength PtsList LL1 LL2 UR1 UR2 Orientation Paper BordersCoords) (setq BorderSizeList (list ;Perimeter : Paper Size Name (P) Paper Size name (L) (cons 39 (list "ANSI A (8.50 x 11.00 INCHES)" "ANSI A (11.00 x 8.50 INCHES)" )) (cons 56 (list "ANSI B (11.00 x 17.00 INCHES)" "ANSI B (17.00 x 11.00 INCHES)" )) (cons 78 (list "ANSI C (17.00 x 22.00 INCHES)" "ANSI C (22.00 x 17.00 INCHES)" )) (cons 112 (list "ANSI D (22.00 x 34.00 INCHES)" "ANSI D (22.00 x 34.00 INCHES)" )) )) (vl-load-com) (defun curvelength ( ent / )(vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))) ;; Lee Mac Suggestion (defun LM:MAssoc ( key lst / pair return ) ; Get 'key' values from dotted pair lists (while (setq pair (assoc key lst)) (setq return (cons (cdr pair) return) lst (cdr (member pair lst))) ) (reverse return) ) (setq MySS (ssget '((0 . "LWPOLYLINE") (-4 . "<OR") (90 . 4) (90 . 5) (-4 . "OR>")))) ; 4 or 5 points polylines (setq acount 0) ; A counter (while (< acount (sslength MySS)) ; Loop through Selection set MySS (setq MyPoly (ssname MySS acount)) ; nth item in MySS entity name (setq MyEnt (entget MyPoly)) ; nth item in MySS entity description (setq MyPolyLength (curvelength MyPoly)) ; Length of the polyline (setq fortytwomax 0) (foreach n (lm:MAssoc 42 MyEnt) (setq fortytwomax (max (abs n) fortytwomax))) ;Get maximum Polyline segment arc radius (if (and ; If: (or ; Poplyline is closed rectangle: (equal (assoc 10 MyEnt) (assoc 10 (reverse MyEnt)) 0.05 ) ; start / end point equal +/- 0.05 (equal (assoc 70 MyEnt) '(70 . 1)) ; 'closed' polyline ) ; endor (= 0 fortytwomax) ; Max segment radius 0: Straight lines only (or ; And polyline Length is border length (equal MyPolyLength 39 0.4) ; +/- 10% (equal MyPolyLength 56 0.6) ; +/- 10% (equal MyPolyLength 112 1.15) ; +/- 10% ) ) ; end and (progn (setq PtsList (lm:MAssoc 10 MyEnt)) ; Get list of polyline points (setq LL1 (car (car PtsList)))(setq LL2 (cadr (car PtsList))) ; Work out lower left / upper right coordinates (setq UR1 (car (car PtsList)))(setq UR2 (cadr (car PtsList))) (foreach n PtsList (setq LL1 (min (car n) LL1)) (setq LL2 (min (cadr n) LL2)) (setq UR1 (max (car n) UR1)) (setq UR2 (max (cadr n) UR2)) ) (if (< (- UR1 LL1) (- UR2 LL2)) (setq Orientation 0)(setq Orientation 1)) (setq Paper (nth Orientation (cdr (assoc MyPolyLength BorderSizeList)))) (if (< (- UR1 LL1) (- UR2 LL2)) (setq Orientation "P")(setq Orientation "L")) (setq BordersCoords (cons (list Paper Orientation (list LL1 LL2) (list UR1 UR2)) BordersCoords)) ; make list of all border coordiantes (redraw MyPoly 3) ; remove this line if happy with selection ) ;end progn ) ; end if (setq acount (+ acount 1)) ) (princ (length BordersCoords)) (princ " Borders Found. ") (getstring "\nHit Enter to remove highlights") ; remove this line if happy with selection (command "regen") ; remove this line if happy with selection (princ "\n Coordinates List: Ansi-Papersize Orientation (LL Cord) (UR Coord) ") (princ "\n")(princ BordersCoords) (princ) ) Edited May 19 by Steven P 2 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.