Jump to content

Possible to determine if layouts have content from Lisp?


lewiswlawrence

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.:oops:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

I think someone is a little obsessed with ObjectDBX... :P

 

Admittedly, I am fascinated with it (ObjectDBX). :oops:

 

However, I do genuinely feel that it would help with the OP's request. o:) 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).

Link to comment
Share on other sites

Admittedly, I am fascinated with it (ObjectDBX). :oops:

 

However, I do genuinely feel that it would help with the OP's request. o:) 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.

Link to comment
Share on other sites

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 by BIGAL
returns nil not 0
Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...