lewiswlawrence Posted May 21, 2011 Share Posted May 21, 2011 Hello, Dueto many Acquisitions over the years the company I work for has inherited a hugevariety of AutoCAD content, tens of thousands of files. This has been producedby different companies to different standards using a variety of AutoCADversions. Some files use only Modelspace, while others use a number ofPaperspace Layouts. The actual drawing content is good and fit for manufactureand needs to be made accessible. Our team are no strangers to writing code andmanipulating data, but Lisp is not a skill set we have and we are fumbling ourway along blindly using snippets of code from the Internet. Searching thisforum there is a lot of excellent content, but nothing that explicitly answersmy question. Currentlywe are using a command line program to launch AutoCAD 2011 to produce a PDF“print” of the content. This PDF is stored with the AutoCAD file and accesseddirectly by non CAD users from the Manufacturing system. During the PDFproduction process we are using a lisp routine to get a list of all the Layouts(getlayoutlist) in the file. This list is exported to a TXT file which is thenused to control the printing process, the result is that we get a PDF file foreach Layout in the AutoCAD file and one for modelspace. Finally we collate andwatermark the pages into a single PDF file using iText. The problem we have isthat many files only have content in modelspace, and for those files we aregenerating a blank PDF for Layout1. Similarly if there is a valid Layout1, weare printing some content twice when we add the modelspace output. Isit possible to make our Lisp program determine if a layout has content or not?If we could do that we could be smarter about what we include in the printoutput. Any other guidance would really be appreciated, perhaps someone knowsof a better way to do what we need? Thanks in advance, ----- Lewis Quote Link to comment Share on other sites More sharing options...
Organic Posted May 21, 2011 Share Posted May 21, 2011 It is pobbile to check if a layout contains anything or not (although an empty viewport will probably return a true value) I believe. You might also want to look into your space bar and whether it works properly on the keyboard you are using. Quote Link to comment Share on other sites More sharing options...
lewiswlawrence Posted May 21, 2011 Author Share Posted May 21, 2011 Thank you for replying and sorry about the absent spaces inmy original post, I actually typed the message in another application and pastedthe txt to the browser, must be something weird going on there. I have takenmore care to review this post and have removed txt formatting, hopefully it looks better. Could you please enlighten me as to how Lisp could be madeto check if a Viewport contains anything? I was imagining doing some kind of “Selectall” and counting the return, but I am not sure if Select all is possible, orif I should just be checking for a particular type of object? Quote Link to comment Share on other sites More sharing options...
lewiswlawrence Posted May 21, 2011 Author Share Posted May 21, 2011 Ok, the spaces were in the txt box when I typed my last post. Which was uploaded from Internet Explorer 9. I am attempting this post using Firefox 4.0 just to see if it behaves better. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted May 21, 2011 Share Posted May 21, 2011 It is pobbile to check if a layout contains anything or not (although an empty viewport will probably return a true value) I believe. Yes it is possible, I would look into using an ObjectDBX query function. It is capable of checking an entire directory of drawings in seconds. You might also want to look into your space bar and whether it works properly on the keyboard you are using. LoL Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2011 Share Posted May 21, 2011 Yes it is possible, I would look into using an ObjectDBX... I think someone is a little obsessed with ObjectDBX... Quote Link to comment Share on other sites More sharing options...
BlackBox Posted May 21, 2011 Share Posted May 21, 2011 I think someone is a little obsessed with ObjectDBX... Admittedly, I am fascinated with it (ObjectDBX). However, I do genuinely feel that it would help with the OP's request. It's the only (fast) way I know to query a directory (multiple directories?) to determine if objects exist on the layout (other than the layout/pviewport itself). Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2011 Share Posted May 21, 2011 Admittedly, I am fascinated with it (ObjectDBX). However, I do genuinely feel that it would help with the OP's request. It's the only (fast) way I know to query a directory (multiple directories?) to determine if objects exist on the layout (other than the layout/pviewport itself). I just notice its frequent occurrences in many of your posts :wink: True, its a powerful way to interface with the drawing database of a file, but one must be aware that it does have many bugs since ADesk stopped its development after moving to .NET. In my opinion, ODBX is best applied to operations involving reading the database (as perhaps in this case), but making no modification. As soon as modification is made, the bugs start to appear (such as loss of Drawing Thumbnail, Text mis-alignment etc). But, yes, it is certainly the fastest way to process any number of drawings in one go. If the OP does decide to follow this route, this program may be of some assistance. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 23, 2011 Share Posted May 23, 2011 (edited) Back to the post A simple is anything there its easy to go to each layout tab and do a selection set with the 410 set to the name of the layout tab something like (setq ss2 (ssget "x" '((410 . "MY TAB1")))) (setq n (sslength ss2)) if n is Nil then its blank also n gives a total of the number of objects. From here theres various ways of what you may do next. You can make a SLD or better a jpg and write them out and use explorer thumbnails to see blank sheets. Maybe delete layouts of 0 objects (always back up first). Edited May 23, 2011 by BIGAL returns nil not 0 Quote Link to comment Share on other sites More sharing options...
lewiswlawrence Posted June 1, 2011 Author Share Posted June 1, 2011 Folks, Thanks for the good advice, we are pretty close to having what we need but are struggling with something we hope you can help with. The full script is in the attached txt file, and the problem is with using the variable "layoutName" in the line (setq ss2 (ssget "x" '((410 . layoutName)))) The line works if we use a known layout name entered as txt. E.G. (setq ss2 (ssget "x" '((410 . "Layout1GDP")))) Any assistance would be appreciated, thanks in advance, ----- Lewis layout.txt Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 2, 2011 Share Posted June 2, 2011 Knew I had seen this before had same problem (setq name layoutabname) etc then (setq ss2 (ssget "_X" (list (cons 410 name))) Quote Link to comment Share on other sites More sharing options...
lewiswlawrence Posted June 8, 2011 Author Share Posted June 8, 2011 Folks, Thanks for the good advice, we got what we needed using the attached script. Hope it is useful to someone else. ----- Lewis LayoutNav_final.txt Quote Link to comment Share on other sites More sharing options...
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.