Jump to content

Page Setup LISP Idea


Ohnoto

Recommended Posts

Tried to download your dwg didn't work but had a look at shapes to view outlines and its pretty easy.

 

This manual way make your outlines a pline clipboard copy & paste to a layout you have to rescale it true size we normally have our title block at a 1:1 scale (in metric 1:500= 2 times so rescale x2) make a new mv using Polygon and trace shape select centrepoint and use zoom c at scale all done. It could all be automated just pick plines in order.

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

Here is the start of some code. It is obviously not finished, but there are notes next to parts that I haven't been able to quite get to work.

 

(defun c:ins ()
 (setvar "cmdecho" 0)
 (if (null extekScale) (setq extekScale 30))
 (command "_.Undo" "Begin")
 (EXTEK_StartErrorTrap)
 (vl-load-com)
 

 (setq PGSBlockName
    '("OUTLINE"))
 

 ;;; --- Select the Running Line ---
  (setq pgsrunline
    (LM:Select "\nSelect Running Line: "
      '(lambda ( x )
         (not
           (vl-catch-all-error-p
           (vl-catch-all-apply 'vlax-curve-getendparam (list x))
           )
         )
       )
       entsel
     )
   )
 

;;; --- Select the Scale ---
 (setq pgsscale (getint (strcat "\n Block Scale factor [30/50/100] <" (itoa (setq pgsscale extekScale)) "> : ")))
 (if (null pgsscale) (setq pgsscale extekScale))
           (while (and (/= pgsscale 30) (/= pgsscale 50) (/= pgsscale 100))
               (setq pgsscale (getint (strcat "\n Block Scale factor [30/50/100] <" (itoa (setq pgsscale extekScale)) "> : ")))
               (if (null pgsscale) (setq pgsscale extekScale))
               )
           (setq extekScale pgsscale)
           (Cond
               ((= extekScale 30) (setq pgsscale "1.0000"))
               ((= extekScale 50) (setq pgsscale "1.6667"))
               ((= extekScale 100) (setq pgsscale "3.3333"))
               ('T ((setq extekScale 1.0000) (princ "\n  !!! SCALE ERROR !!!\n"))))


;;; --- Insert the outline block along the running line, putting it at the specificied       
;;;     scale from above and increasing page number attribute value by 1 for each insert  ---
;;; --- 30 Scale at 396' / 50 Scale at 660' / 100 Scale at 1320' ---

 (EXTEK_EndErrorTrap)
 (setvar "cmdecho" 1)
 (princ)
 )


;;; ----------------------------------------------------------------------------------------- ;;;
;;; ---------------------------------------- Create Pages ----------------------------------- ;;;
;;; ----------------------------------------------------------------------------------------- ;;;


(defun c:pgs ()
 (setvar "cmdecho" 0)
 (command "_.Undo" "Begin")
 (EXTEK_StartErrorTrap)
 (vl-load-com)
 

;;; --- Select the Outline Block ---
 (if (setq ss (ssget ":L"
                     (list '(0 . "INSERT") '(66 . 1)
                           (cons 2
                                 (apply (function strcat)
                                        (cons "`*U*,"
                                              (mapcar (function (lambda (s) (strcat s ",")))
                                                      PGSBlockName)))))))

;;; --- Extract the attribute page name ---
   

;;; --- Extract "Block Angle" dynamic value ---
(command "LAYOUT" "NEW" page)

   
;;; --- Create viewport and set up area ---
(command "DVIEW" "" "TWist" (- outlineangle) "")
(c:rn) ;;; A program of ours that automatically rotates our north arrow on a specific page.

(EXTEK_EndErrorTrap)
(setvar "cmdecho" 1)
(princ)
)





;;---------------------=={ Select if }==----------------------;;
;;                                                            ;;
;;  Continuous selection prompts until a predicate function   ;;
;;  is validated                                              ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  msg  - prompt string                                      ;;
;;  pred - optional predicate function taking ename argument  ;;
;;  func - selection function to invoke                       ;;
;;------------------------------------------------------------;;
;;  Returns:  selected entity ename if successful, else nil   ;;
;;------------------------------------------------------------;;

(defun LM:Select ( msg pred func / e ) (setq pred (eval pred))  
 (while
   (progn (setvar 'ERRNO 0) (setq e (car (func msg)))
     (cond
       ( (= 7 (getvar 'ERRNO))

         (princ "\n** Missed, Try again **")
       )
       ( (eq 'ENAME (type e))

         (if (and pred (not (pred e)))
           (princ "\n** Invalid Object Selected **")
         )
       )
     )
   )
 )
 e
)

 

 

I re-uploaded the outline block, I adjusted the size of it a bit, and it's saved down to release 2000.

outline.dwg

Link to comment
Share on other sites

I still can not see why you are using blocks rather than plines on a layer your drawing on other page has random shapes as the outlines so how can you have 1 block ? would you not just create pline rectangs as a first step then modify then run a seperate second step which is to read the plines wether their rectang or multi sided maybe also a angle line for orientation first line in pline, then they can be recreated easily in a layout tab. One hint when you get the polylines in one go you need to make sure you have drawn them so next is touching previous else you will get out of sequence as they are retrieved in created order not location. Ps Yeah I know how to fix this also. Also have you allowed for any overlap in the sheets or they having a cut/join line only ?

 

Quick suggestion you can reduce code by forcing only valid responce ie enter 30 50 100 or else will keep asking use "initget" and "getkword" (Initget 0 30 50 100) (setq ans (getkword "\enter scale 30 50 100"))

 

I would do step 2 first as thats the harder bit the code posted previously for working out where you are on the pline is nearly there.

Link to comment
Share on other sites

Those random shapes shown on the other page were done using that block. The reasoning behind the block is that it contains information needed. The block has a drop down visibility for each scale, attribute for page name (which can have the value determined when inserting, starting with 01 then adding one. Then it can be used to sort the order of pages, and be the title of the page tab), and then angle for the view angle.

 

If visibility is on 30 scale, viewport would be set up to 1/30xp

If visibility is on 50 scale, viewport would be set up to 1/50xp

If visibility is on 100 scale, viewport would be set up to 1/100xp

 

Thanks for that suggestion, that piece of code was written by our previous LISP writer who left us several months ago and since then I've had to teach myself using his these forums, a book and his coding, and I've seen several parts of his coding that was written using more coding than necessary.

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