Jump to content
wannabe

WTD: Script Tutorials & Examples

Recommended Posts

ReMark

All very good points Dave. Makes a lot of sense.

Share this post


Link to post
Share on other sites
MiGo

Can you write an IF statement into a script?

I am currently working on a big script to dumb down all drawings required for a client. The final drawings will all be model space drawings only, will contain no yellow, and will have all xrefs bound exploded and trimmed. So my script will be run Using ScriptPro so I can just run it on all drawings selected. As of now script pro opens drawing, my scrip will then save the drawing as the same name but with "acad-" on the front, take and explode all dimensions (i know it's horrible but it's required), burst all blocks in modelspace with atributes, then expload all blocks (repeats 2x for any blocks of blocks of blocks...), then will copy all in model, then will go into first viewport, draws outline of viewport extents, uses that to trim everything outside that viewing area, scales the line up a smidge to erase any text touching the line that may exceed the limits of the viewport, erases that line, then chspace all items withing that viewport, erases all that's left in model, pastes original model space objects, and repeats for up to 10 viewports (I create a dummy viewport so after the normal layout viewport max has been met all of the chspace goes to a dummy one that is deleted later), then it will copy all in paper from 0,0,0, and paste it into model, purge and udit save and script pro will exit drawing at end of script.

 

So what i'm hoping to do is at the end of each section if the max # of viewports has been met it will finish the drawing conversion to model, and exit. To eleminate having to do the process over and over past the initial # of viewports. The IF line that I have in there now (that doesn't work) is:

(if (eq (length (vports)) "1")

...do something here

)

 

I get a syntax error.

Any help would be great.

Share this post


Link to post
Share on other sites
ReMark

MiGo: I see your question has gone unanswered. I suggest you post it as a new thread and see if that attracts any replies.

Share this post


Link to post
Share on other sites
dbroada

in general you can only do in a script what you can do at the keyboard, therefore no branches etc.. It is possible to call a LISP statement but just using what you have will give you a missing parenthesis error. Try it with the whole statement on a single line and see if it works then.

Share this post


Link to post
Share on other sites
MiGo

I have sucessfully put my If statement into my script as well as many others, and it has grown guite a bit. I wanted to make it to automate a lengthy process on all of a partictular clients drawings. so far the script saves a copy of the original explodes dims in paperspace, explodes all dims in model, bursts all blocks in model (multiple times), trimms and deletes everything outside each viewport, converts thepaperspace contents to model at the original paper size, then removes all yellow from everything.

 

The only snag that I ran into was the fact of putting instances of Extrim, Burst, and other Lisps that require a selection and points inside the if, so for now I just run the routine up to 20 viewports and it performs finishing commands upon completing the last viewport for the layout tab.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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