Jump to content

Page Setup LISP Idea


Ohnoto

Recommended Posts

One of the most tedious things that I personally dislike doing is setting up pages. Doing civil engineering we could be doing something that is miles long, at which point I just want to bang my head on my desk. Our typical scale is 30, which is about 11-12 sheets per mile, or 50 scale which is about 8 per mile.

 

Is there a way that pages and viewports could be set up automatically following a specific line?

 

The command processing would be:

Select the running line.

Prompt for distance amount per viewport.

Prompt for the viewport scale.

 

Is this even possible?

Link to comment
Share on other sites

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • Ohnoto

    12

  • BIGAL

    6

  • BlackBox

    5

Top Posters In This Topic

Posted Images

Just regular ACAD 2011.

 

We have one computer here that has Civil 3D on it, but its for our surveyor, and with us being a small company, I know that they won't spring to get Civil 3D with us already having ACAD. I will be trying out that feature though on it. It would be nice if in regular ACAD to be about to do something like that where you could select a box in model space and that would setup the viewport would be awesome also, possibly set it up as a block that would have our matchline station in it also.

Edited by Ohnoto
Link to comment
Share on other sites

Have you considered going into one of your title blocks in paper space (for each size), draw a rectangle over your viewport (scaled accordingly), then chspace the rectangle to model space, create a block from that rectangle, and use the measure, or divide command?

 

Does that sound like what you're after? :unsure:

Link to comment
Share on other sites

Don't think so, since that wouldn't set up pages. It looks like from the link you provided that you set up rectangles in Civil 3D, select those and pages are set up? I'm currently download a trial of Civil 3D at home to mess around with it. But is that how it works?

 

Don't mind the rambling from the last posting... on our model space matchlines we have attributes for stationing to quickly compare it to the stationing of the paperspace. I was thinking if it was possible select an object or group of objects and have pages set up from those, that I would have a rectangle box with an attribute of our model space stationing in it, which could also be a way to determine an order of setting up pages. We then link our paper space matchline text to our model space one with a LISP program so that if the model space one is updated, it updates automatically on paper space.

 

However... it would be nice to have something like that for Plain Jane AutoCAD also... Which is probably what I would try for if that would be possible. I'm just not quite sure if that is.

Link to comment
Share on other sites

It would be nice if in regular ACAD to be about to do something like that where you could select a box in model space and that would setup the viewport would be awesome also, possibly set it up as a block that would have our matchline station in it also.

 

That's one of the many reasons to upgrade to Civil 3D, bud... Alignments, Profiles, etc. :lol: LoL

 

Don't think so, since that wouldn't set up pages. It looks like from the link you provided that you set up rectangles in Civil 3D, select those and pages are set up? I'm currently download a trial of Civil 3D at home to mess around with it. But is that how it works?

 

Basically it would be nice to have something like that for Plain Jane AutoCAD also... Which is probably what I would try for if that would be possible. I'm just not quite sure if that is.

 

 

I would write two, separate routines:

  • One for creating the frames along your alignment
    1. Select alignment (polyline?)
    2. Prompt for desired sheet scale (30, 50, etc.)
    3. Create frames along your alignment, on the right layer, etc.

    [*]One for creating your sheets

    1. Create a selection set of frames (a Frame Group)
    2. Prompt the user for starting sheet number/name
    3. Create a stored list of grouped pairs containing FileName, and Coordinates of the corrisponding frame
    4. Initialize ObjectDBX
    5. For each grouped pair in your stored list

      1. Open your template (DWT) using ODBX
      2. Step through the DBX Doc's model space Layout Object's Block
        1. Attach your external reference(s)
        2. Perhaps recreate the frame in model space
        3. [*]Step through the DBX Doc's paper space Layout Object Block

          1. Insert your title block
          2. Create your viewport
          3. Manipulate the Viewport Object's CustomScale, SnapAng, and Target Properties

          [*]Use ODBX to SaveAs your drawing with the FileName in your Grouped Pair

          [*]Release ODBX

          [*]Send any reporting data you feel prudent to the command line

          [*](princ)

          Edit - Among other things, don't forget to perform all of the necessary layer checks and/or modification to the Layers Collection for each DBX Doc. :wink:


Link to comment
Share on other sites

For selection and stored list of the frames, do you think it could be done using blocks with stationing in them, and then using VL-Sort?

 

And as for the process... I'm just going to look up and watch it go right over my head... :lol:

 

Our drawings are set up a bit different than what you may be thinking also. When we start a project, we start with our template, which holds all of the company borders that we work with in it, which then we delete out the ones we don't need, so our first page is always set up with what ever company our project is for, even complete with a viewport already, which may have to be removed for this process. Which is where I'm confused about the part of opening our template, using ODBX (Which is a new concept to me), etc.

 

I think I could write that first LISP just fine, though my only issue would be determining where a second frame would go after the first, but that second routine... there's a lot of concepts in there I haven't heard of or used yet. Which I am more than eager to learn about, my primary way of learning though is hands on, doing and seeing the outcomes.

Link to comment
Share on other sites

No worries... the outline above is the workflow for a routine I've been working on for some time to provide my team this "Page Setup", or "Sheet Creator" functionality (before I found out we're moving to Civil 3D 2011). LoL

 

I'm headed out the door now, but would like to help get you started... Like I said, I've already written some of it, I'm sure there will be changes needed to suit your situation.

 

~RM

Link to comment
Share on other sites

Awesome! I can't tell you how much I appreciate any assistance you could provide. I just know that the owner here won't go for getting Civil 3D for 6-8 drafters when we can do most everything we want currently in regular ACAD. They just wouldn't see the worth in it for a few things.

Link to comment
Share on other sites

You're welcome. I'll be able to help you more tomorrow (on my iPhone now). LoL

 

We'll work out where your boss can send me a bonus later lmao.

Link to comment
Share on other sites

@Lee... Cause I know you are reading this from the posting in the Chat section. Obviously, I don't want to post about this LISP there.

 

I am going to try and be as detailed as possible in describing my idea on how this works, including how we do things at my job, since it varies a bit from the outline above. Though even something more general would probably be more beneficial to others as well.

 

As stated above, the current idea is two LISP programs.

 

First Routine:

The user would select a polyline, which for us is continuous from start to end of our project and what we take our footages off of.

 

It would then ask for 30/50/100 scale - Here I would perfer it to insert the outline block with visibilities of 30/50/100. This block would then be placed along the the previously selected polyline in increments based on the scale size.

 

From here a user would verify the outline, make sure things are the right direction with the block, because as this line adjusts or turns down other roads, there could be some minor issues.

Second Routine:

With the outline block, I would include stationing attributes, which could be used to sort which blocks would be placed in order.

 

Here a DCL would probably be best, where you could select the border block to use, listing anything with "BORDER" in the name. However, it would prompt which border to use.

 

We name our pages as 01 , 02 , 03 ... so there shouldn't be any need to prompt for what to name the pages since it the current name +1.

 

From here it would set up the borders based on the sort order, rotating and setting the extent corners based on each block.

 

Then as it sets up the page, I have a rotate north arrow LISP already that I would like to include into it as it goes.

 

 

I hope this clears up any questions you had about this LISP, but if it didn't, just let me know.

Link to comment
Share on other sites

My attempt

 

Pick pline and work out spacing including slight overlap remember centre pt's of box create a ucs for each pt aligned to pline at that point! Curves and direction change then no problem.

 

You know how many pts = num of layouts required using preferred titleblock

 

Create new layout tricky bit (Lee ??) jump into viewport and simply change UCS to correct box Plan etc zoom C to centre of box and set correct scale

 

Repeat step above for all views.

 

Add some code "gasp" and fill sheet details as you go.

 

Found the first couple of steps put in loop

(command "_.layout" "_n" layoutname) (setvar "ctab" layoutname) keep going from here insert title block add mview etc then zoom thought it would be hard to jump into view but just mview create them "mspace"

Edited by BIGAL
had a go
Link to comment
Share on other sites

Real rough but is an example of how it could be done

 

(setq x 1)
(setq pt1 "0,0")  ;this becomes the new cen pt for each title
(repeat 5            ; how many required
(setq layoutname (rtos x 2 0))
(command "_.layout" "_n" layoutname) 
(setvar "ctab" layoutname)
(command "mview" 0,0 100,100)
(command "zoom" "e")
(command "mspace")
; need a new ucs here
(command "Zoom" "c" pt1 100)
(setq x (+ x 1 ))
)

 

 

Visited a consultant we use today and they have to meet various client needs in the way dwgs are presented to them, individual dwgs per sheet, dwgs in model space, dwgs in 1 paperspace so they can see all at once. Mind boggling. We have model & layouts simple

 

Bottom line though a single routine could do all if you draw parts but want on multi tabs it may be usefull draw 1 pline below parts and it makes the sheets.

 

I need to get calc pline at interval its somewhere here add to above and its 1/2 way there any one else want to have a go ? I am happy to add more even though we use CIV3d.

Edited by BIGAL
visit today
Link to comment
Share on other sites

For doing the UCS, because we don't do any modifying of that specifically. Should be able to get the angle of the outline block and do something like...

 

(command "DVIEW" "" "TWist" (- outlineangle) "")

Link to comment
Share on other sites

I'm eager to get this going and see what we can get done with this, but would like to see what you had started before.

Link to comment
Share on other sites

I'm not quite sure what you are doing in that thread? Is that simply creating the viewport and then zooming to an area? The first posting on this page (2) has a bit more detail on what I am working on. Hopefully tomorrow, or later tonight, I'll be able to actually start writing some code for it.

Link to comment
Share on other sites

I posted some code above what I did not post is the work out each centre for each title block, you do not need to insert a rectang to show sheet unless you want to.

Replace this

(setq pt1 "0,0") ;this becomes the new cen pt for each title

with pt1 = new centre pt on pline repeated as required given length of a title block and you will have multi layout tabs a bit more customising is required regarding naming etc but its awlfull close. Been working on some thing else otherwise it would have been done.

 

Ch labels equal spacing on polyline downloaded from here. it works out the sq to pline which is important instead of labels just need point and the add make new layout tab.

 

(defun div-error (msg)
 (if
   (vl-position
     msg
     '("console break"
"Function cancelled"
"quit / exit abort"
      )
   )
    (princ "Error!")
    (princ msg)
 )
 (while (> (getvar "cmdactive") 0) (command))
;;;  (command "._undo" "_end")
;;;  (command "._u")
 (setq *error* olderror)
 (princ)
)
(defun divplus (len segm / num lst)
 (setq num (fix (/ len segm)))
 (setq cnt 0)
 (while (<= cnt num)
   (setq tmp (* cnt segm))
   (setq lst (append lst (list tmp)))
   (setq cnt (1+ cnt))
 )
 (setq delta (- len (last lst)))
 (if (not (zerop delta))
   (setq lst (append lst (list (+ (last lst) delta))))
   lst
 )
)
(defun divminus (len segm / lst)
 (while (>= len 0.)
   (setq lst (append lst (list len)))
   (setq len (- len segm))
 )
 (if (not (zerop (last lst)))
   (setq lst (append lst (list 0.0)))
 )
 lst
)
(defun alg-ang (obj pnt)
 (angle '(0. 0. 0.)
 (vlax-curve-getfirstderiv
   obj
   (vlax-curve-getparamatpoint
     obj
     pnt
   )
 )
 )
)
(defun answer (quest / wshl ans)
(or (vl-load-com))
(setq wshl (vlax-get-or-create-object "WScript.Shell"))
(setq ans (vlax-invoke-method
 wshl
 'Popup quest 7 "Answer This Question:" vlax-vbYesNo))
(vlax-release-object wshl)
(cond  ((= ans 6)
      (setq opt T))
      ((= ans 7)
      (setq opt nil))
      )
 opt
)

(defun make-station (bname /  acsp adoc atprom attag at_obj
      blk_obj hgt lay line_obj sfar )
 (vl-load-com)
 (setq adoc (vla-get-activedocument
       (vlax-get-acad-object)
     )
 )
 (if (and
(= (getvar "tilemode") 0)
(= (getvar "cvport") 1)
     )
   (setq acsp (vla-get-paperspace adoc))
   (setq acsp (vla-get-modelspace adoc))
 )
 (vla-startundomark adoc)
 (if (not (tblsearch "block" bname))
 (progn
 (setq attag  "NUMBER" ;(strcase (getstring "\nAttribute tag : \n"))
atprom "NUMBER" ;(strcase (getstring T "\nAttribute prompt : \n"))
hgt    1.0 ;(getreal "\nAttribute text height : \n")
 )
 (setq lay (getvar "clayer"))
 (setvar "clayer" "0")
 (setvar "attreq" 0)
 (setq line_obj (vlax-invoke acsp 'Addline '(0. 0. 0.) (list 0. (* hgt 12.) 0.)))
 (vla-put-color line_obj acyellow)
 (setq blk_obj (vla-add (vla-get-blocks adoc) (vlax-3d-point '(0. 0. 0.)) bname)
sfar (vlax-safearray-fill
   (vlax-make-safearray vlax-vbObject '(0 . 0))
   (list line_obj)
 )
 )
 (vla-copyobjects adoc sfar blk_obj)
;;;  RetVal = object.AddAttribute(Height, Mode, Prompt, InsertionPoint, Tag, Value) 
 (setq at_obj (vla-addattribute blk_obj
  hgt
  acattributemodeverify
  atprom
  (vlax-3d-point '(-0.5 1. 0.))
  attag
  "0+00")
)
;;;  (vla-put-alignment at_obj acAlignmentBottomCenter)
;;;  (vla-put-textalignmentpoint
;;;    at_obj
;;;    (vlax-3d-point '(0. 1. 0.))
;;;  )
 (vla-put-rotation at_obj (/ pi 2))
 (vlax-release-object blk_obj)
 )
 (progn
     (princ "\n\t >> Block does already exist!\n")
   (princ)))
 (if (tblsearch "block" bname)
   T
   (progn
     (alert "Impossible to add block")))
 (setvar "attreq" 1)
 (setvar "clayer" lay)
 (vl-catch-all-apply (function (lambda ()(vla-delete line_obj))))
 (vla-regen adoc acactiveviewport)
 (vla-endundomark adoc)
 (vlax-release-object acsp)
 (vlax-release-object adoc)
 (princ)
)
(or (vl-load-com))
(defun C:d10 (/ *error*  acsp   adoc    appd     div-error
       len num  olderror pl    pt     pt_list
       step util
      )
 (or adoc
     (setq adoc
     (vla-get-activedocument
       (vlax-get-acad-object)
     )
     )
 )
 (or appd (setq appd (vla-get-application adoc)))
 (or acsp
     (setq acsp
     (vla-get-block
       (vla-get-activelayout adoc)
     )
     )
 )
 (or util (setq util (vla-get-utility adoc)))
;;;  (command "._undo" "_end")
;;;  (command "._undo" "_mark")
 (setq olderror *error*)
 (setq *error* div-error)
;;;  (setq bname  (getstring T "\nStation block name : \n"))
;;;  (make-station bname)
 (if (not (tblsearch "block" "Station"))
 (make-station "Station"))
 
 (vla-getentity
   util
   'pl
   'pt
   "\nSelect line NEAR OF POINT TO START measure: >>> \n"
 )
 (if pl
   (progn
 (setq step (getreal "\nEnter step for stationing <10> : \n"))
 (setq opt (answer "Rotate text perpendicularly to pline?"))
 (if (not step)(setq step 10.))
 
     (setq len (vlax-curve-getdistatparam
   pl
   (vlax-curve-getendparam pl)
 )
     )
     (if (< (distance (vlax-safearray->list pt)
        (vlax-curve-getstartpoint pl)
     )
     (distance (vlax-safearray->list pt)
        (vlax-curve-getendpoint pl)
     )
  )
(setq pt_list (divplus len step))
(setq pt_list (divminus len step))
     )
     (setq
pt_list (vl-remove-if
   (function not)
   (mapcar (function (lambda (x)
         (vlax-curve-getpointatdist pl x)
       )
    )
    pt_list
   )
 )
     )
     (setq num 0)
;;;      (setq num (getint "\nEnter initial station number\n"))
     (mapcar
(function
  (lambda (x / dr ang att_list at blk_obj)
    (progn
      (setq ang (alg-ang pl x)
     ang
  (cond ((< (/ pi 2) ang (* pi 1.5)) (+ pi ang))
        (T ang)
  )
      )
      (setq blk_obj (vlax-invoke
        acsp 'Insertblock x "Station" 1 1 1 ang)
      )
      (setq att_list (vlax-invoke blk_obj 'Getattributes))
      (foreach at att_list
 (if (eq (vlax-get at 'Tagstring) "NUMBER")
   (progn
     (vlax-put at 'Textstring (if (< num 990.)
   (strcat "Ch " (rtos num 2 2))
(strcat "sta: "
(itoa (fix (/ 1200. 1000.)))
"+"
(rtos (- num (* (fix (/ num 1000.)) 1000)) 2 2)
)
))
     (if (not opt)
     (vlax-put at 'Rotation 0))
     (vla-update at)
   )
 )
      )
      (vla-update blk_obj)
      (vlax-release-object blk_obj)
      (setq num (+ num step))
    )
  )
)
pt_list
     )
     (if (not (vlax-object-released-p pl))
(vlax-release-object pl)
     )
   )
   (princ "\nNothing selected try again\n")
 )
 (vla-zoomextents appd)
 (vla-regen adoc acactiveviewport)
 (setq *error* olderror
div-error nil
 )
;;;  (command "._undo" "_end")
 (princ)
)
(prompt "\n")
(prompt "\n *** Type D10 to execute *** \n")
(princ)

Edited by BIGAL
Link to comment
Share on other sites

That LISP appears to reset stationing at every 2000', but I'm not quite clear the intentions of it in regards to this.

 

Below is an image from a recent project, that shows our matchlines and project running line. As seen, our route twists and turns, crosses streets, etc. Viewports are set up at different angles on each page.

 

As much as I like the idea behind having everything in one LISP, there are just too many variables, I think. Such as, a set footage amount falling in the middle of a street and the viewport then set up crossing down the middle of the road, which we don't do.

 

Route.JPG

 

If blocks were inserted, the user could then adjust them, and preferably viewports would then be set up with the same outline shape as the block. From this block the LISP should be able to pull angle information from the block to set the viewport page to, and the page name, based off of the attribute value. Attached is that block.

 

Route Outline.JPG

outline.dwg

Link to comment
Share on other sites

The insert chainage works fine for me I set the spacing to be equal to the size of my mview in the layout tab I found a spot to put the make new layout tabs within this code, if you run it and change the block "station" to be say a rectang then you should be able to see how its going to work. I found the pt_list contains all the points along the pline so thats step 1, step 2 is to add the ang of the title block at this point.

 

If you want shaped dwg areas then forget the way above you need a totally different approach it would actually be a bit easier as you have already worked out the size at scale. Just pick the pline outline and new layout created it would use a control pt which should be on the pline. You just need to work out the scale factor for a new pline mview in a layout tab.

 

I am still going to do the sq shape as we have a need for it.

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