Jump to content

WTD: Script Tutorials & Examples


wannabe

Recommended Posts

  • 2 months later...
  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • ReMark

    14

  • dbroada

    5

  • wannabe

    3

  • MiGo

    2

Top Posters In This Topic

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

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