Author Topic: Viewport Lisp  (Read 5002 times)

0 Members and 1 Guest are viewing this topic.

One Shot

  • Guest
Viewport Lisp
« on: March 03, 2005, 03:15:44 PM »
I am trying to set a viewport on A-Anno-Spce-Nplt .  Can someone help with this.  This is what I got so far.  I don't think that it will work.  I would like it to add the layer A-Anno-Spce-Nplt with color 8.  It would need to have the print turned off.

Thank you for your help.

This is my first lisp that I tried to write.



  ;   File Name: Revision Viewport Non Plot.LSP
    ;   Description: Puts Viewports on its own Not Plot Layer so it will not plot.  
    ;
    ;*******************************************************************************
(defun C:vport-nplt (/ SSetLayer)
   (setq SSetLayer (ssget "_X" '((8 . "A-Anno-Spce-Nplt"))))
   (if SSetLayer
    (command "._A-Anno-Spce-Nplt" SSetLayer "")
   )
   (princ)
 )

One Shot

  • Guest
Re: Viewport Lisp
« Reply #1 on: March 03, 2005, 03:23:53 PM »
Quote from: One Shot
I am trying to set a viewport on A-Anno-Spce-Nplt .  Can someone help with this.  This is what I got so far.  I don't think that it will work.  I would like it to add the layer A-Anno-Spce-Nplt with color (8).  It would need to have the print turned off.

Thank you for your help.

This is my first lisp that I tried to write.



  ;   File Name: Revision Viewport Non Plot.LSP
    ;   Description: Puts Viewports on its own Not Plot Layer so it will not plot.  
    ;
    ;*******************************************************************************
(defun C:vport-nplt (/ SSetLayer)
   (setq SSetLayer (ssget "_X" '((8 . "A-Anno-Spce-Nplt"))))
   (if SSetLayer
    (command "._A-Anno-Spce-Nplt" SSetLayer "")
   )
   (princ)
 )


Can youu please move this to the Lips forum.  I put it here by mistake

Thank you,

VerticalMojo

  • Guest
Viewport Lisp
« Reply #2 on: March 03, 2005, 03:28:50 PM »
Done!  :loneranger:

One Shot

  • Guest
Viewport Lisp
« Reply #3 on: March 03, 2005, 03:31:28 PM »
Quote from: VerticalMojo
Done!  :loneranger:


Thank you!

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Viewport Lisp
« Reply #4 on: March 03, 2005, 03:37:17 PM »
I have this in VBA if you cant figure it out.  Sorry, my LISP is really bad
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Viewport Lisp
« Reply #5 on: March 03, 2005, 03:43:21 PM »
So the VP's are existing and you want to gather them all up in one sset them put them on the "A-Anno-Spce-Nplt" layer, and set that layer to "no plot"?
TheSwamp.org  (serving the CAD community since 2003)

One Shot

  • Guest
Viewport Lisp
« Reply #6 on: March 03, 2005, 03:52:45 PM »
Quote from: Mark Thomas
So the VP's are existing and you want to gather them all up in one sset them put them on the "A-Anno-Spce-Nplt" layer, and set that layer to "no plot"?


When yes and more.  

Your lisp to your question!

Gather them up and put them to the A-Anno-Spce-Nplt and set the layer to color 8 and set the layer to "no plot".   (yes)



My lisp to my question!

Add a VP and have them go to the A-Anno-Spce-Nplt and set the layer to color 8 and set the layer to "no plot".   (yes)


Thank you,

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Viewport Lisp
« Reply #7 on: March 03, 2005, 03:58:02 PM »
Ok, here's a start. This will create a sset of all the VP's in the dwg. Gotta go ..........
Code: [Select]

(setq ss (ssget "x" '((0 . "VIEWPORT"))))
TheSwamp.org  (serving the CAD community since 2003)

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Viewport Lisp
« Reply #8 on: March 03, 2005, 04:14:01 PM »
If you are creating the vport then you can use this code to create the layer then create the vport then set the layer back:

Code: [Select]
;;; ------------ Sub used to create layers
;;; Call it like this:
;;; (if (not (tblsearch "layer" "G-VPORT-NPLT"))
;;; (CREATE_LAYER "G-VPORT-NPLT" "Non-plotting viewport layer" "Continuous" "18" "7" "0")
;;; )
;;;
;;; (CREATE_LAYER "NAME" "Descriptions" "Linetype" "Thickness" "Color" "Plot") - Plot is "1" NoPlot is "0"
(defun CREATE_LAYER (Layer Descpition Linetype Thickness Color Plot / TmpList)

;; Create a list for entmake
(setq TmpList
    '((0 . "LAYER")
      (100 . "AcDbSymbolTableRecord")
      (100 . "AcDbLayerTableRecord")
      (70 . 0)
      )
  )
;; Create layer name list
(setq TmpList (append TmpList (list (cons 2 Layer))))
;; Create layer color list
(setq TmpList (append TmpList (list (cons 62 (atoi Color)))))
;; Create layer linetype list
(setq TmpList (append TmpList (list (cons 6 Linetype))))
;; Create layer lineweight list
(setq TmpList (append TmpList (list (cons 370 (atoi Thickness)))))
;; Create layer plot list
(setq TmpList (append TmpList (list (cons 290 (atoi Plot)))))
;; Create layer from first item in the list
(entmake TmpList)
;; Create layer description
(if(= 16.1 (atof(getvar "acadver")))
(progn
(setq VLA-Obj(vla-Add (vla-Get-Layers (vla-Get-ActiveDocument(vlax-Get-Acad-Object)))Layer))
(vla-Put-Description VLA-Obj Descpition)
)
)
)


I do this in my titleblock inserting program and it works fine.

If you have anymore question feel free to ask
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

One Shot

  • Guest
Viewport Lisp
« Reply #9 on: March 03, 2005, 04:40:28 PM »
Quote from: TimSpangler
If you are creating the vport then you can use this code to create the layer then create the vport then set the layer back:

Code: [Select]
;;; ------------ Sub used to create layers
;;; Call it like this:
;;; (if (not (tblsearch "layer" "G-VPORT-NPLT"))
;;; (CREATE_LAYER "G-VPORT-NPLT" "Non-plotting viewport layer" "Continuous" "18" "7" "0")
;;; )
;;;
;;; (CREATE_LAYER "NAME" "Descriptions" "Linetype" "Thickness" "Color" "Plot") - Plot is "1" NoPlot is "0"
(defun CREATE_LAYER (Layer Descpition Linetype Thickness Color Plot / TmpList)

;; Create a list for entmake
(setq TmpList
    '((0 . "LAYER")
      (100 . "AcDbSymbolTableRecord")
      (100 . "AcDbLayerTableRecord")
      (70 . 0)
      )
  )
;; Create layer name list
(setq TmpList (append TmpList (list (cons 2 Layer))))
;; Create layer color list
(setq TmpList (append TmpList (list (cons 62 (atoi Color)))))
;; Create layer linetype list
(setq TmpList (append TmpList (list (cons 6 Linetype))))
;; Create layer lineweight list
(setq TmpList (append TmpList (list (cons 370 (atoi Thickness)))))
;; Create layer plot list
(setq TmpList (append TmpList (list (cons 290 (atoi Plot)))))
;; Create layer from first item in the list
(entmake TmpList)
;; Create layer description
(if(= 16.1 (atof(getvar "acadver")))
(progn
(setq VLA-Obj(vla-Add (vla-Get-Layers (vla-Get-ActiveDocument(vlax-Get-Acad-Object)))Layer))
(vla-Put-Description VLA-Obj Descpition)
)
)
)


I do this in my titleblock inserting program and it works fine.

If you have anymore question feel free to ask


Thank you,

Brad

Tim,

Can you shoot me an e-mail?

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Viewport Lisp
« Reply #10 on: March 03, 2005, 04:45:29 PM »
If you give your ad. Sure
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

One Shot

  • Guest
Viewport Lisp
« Reply #11 on: March 03, 2005, 04:47:34 PM »
Quote from: TimSpangler
If you give your ad. Sure


bnc_designs@yahoo.com

One Shot

  • Guest
Viewport Lisp
« Reply #12 on: March 04, 2005, 02:09:10 PM »
Quote from: One Shot
Quote from: TimSpangler
If you give your ad. Sure


bnc_designs@yahoo.com


How would you have this lisp to be able to create the vports? Could it be done in a dialog box with these selections in it?(Fit/Shadeplot/Lock/Object/Polygonal/Restore/2/3/4/Fit)  Also to have to change the print symbol in the layer manager to show Non Plot
Code: [Select]
 ;;; VPLMAKE
;;; Makes the layer A-Anno-Spce-Nplt and places all PS viewports on it
;;; Copyright 2005 Lance Gordon Custom Software
(defun c:vplmake (/ tm filter ss ssctr mctr)
  (setvar "CMDECHO" 0)
  (command "_UNDO" "BEgin")
  (if (not (tblsearch "LAYER" "A-Anno-Spce-Nplt"))
    (command "_-LAYER" "New" "A-Anno-Spce-Nplt" "OFF" "A-Anno-Spce-Nplt" "")
    (command "_-LAYER" "OFF" "A-Anno-Spce-Nplt" "")
  )
  (setq tm (getvar "TILEMODE"))
  (setq filter (list '(-4 . "<AND")
    '(0
      .
      "VIEWPORT"
     )
    '(-4 . "<NOT")
    '(69 . 1)
    '(-4 . "NOT>")
    '(-4 . "AND>")
      )
  ) ; exclude model vport
  (if (setq ss (ssget "X" filter))
    (progn ; retrieve layout names
      (setq llist (layout-list ss))
      (if (= tm 1)
(setvar "TILEMODE" 0)
      ) ; and walk through layouts.
      (setq mctr 0) ; count changed VPs
      (foreach layout llist
(setvar "CTAB" layout)
(if (/= (getvar "CVPORT") 1)
 (command "PSPACE")
) ; be sure we can get at the ports
(setq ssctr 0)
(while (< ssctr (sslength ss))
 (setq cvp (ssname ss ssctr))
 (if (and (= (getvar "CTAB") (cdr (assoc 410 (entget cvp))))
  (/= (cdr (assoc 8 (entget cvp))) "A-Anno-Spce-Nplt")
     ) ; change vp if not already on A-Anno-Spce-Nplt layer
   (progn
     (command "_CHANGE" cvp "" "P" "LA" "A-Anno-Spce-Nplt" "")
     (setq mctr (1+ mctr))
   )
 )
 (setq ssctr (1+ ssctr))
)
      )
    )
    (alert "   No viewports found.")
  )
  (if (= tm 1)
    (progn
      (setvar "TILEMODE" 1)
    )
  )
  (if (> mctr 0)
    (princ
      (strcat (itoa mctr) " viewport(s) placed on layer A-Anno-Spce-Nplt.")
    )
  ) ; Warn that A-Anno-Spce-Nplt is turned off before exiting
  (alert "NOTE: Layer \"A-Anno-Spce-Nplt\" is turned OFF.")
  (command "_UNDO" "End")
  (setvar "CMDECHO" 1)
  (princ)
)
;;; LAYOUT-LIST creates a list of Layout names
;;; where viewports are found.  The selection set
;;; passed with this routine is NOT altered or destroyed.
(defun layout-list (vps / vp el ctr)
  (if (> (atoi (getvar "ACADVER")) 14) ; Check for R14 (one layout)
    (progn
      (setq ctr 0)
      (while (< ctr (sslength vps))
(setq vp (ssname vps ctr))
(setq el (entget vp))
(if (/= (cdr (assoc 69 el)) 1) ; Look for Layout names of VPs
 (if lllist ; and put them in a list
   (if (not (member (cdr (assoc 410 el)) lllist))
     (setq lllist (append lllist (list (cdr (assoc 410 el)))))
   ) ; Append only if not already in the list
   (setq lllist (list (cdr (assoc 410 el))))
 )
)
(setq ctr (1+ ctr))
      )
    )
    (progn ; If this is R14,
      (setq vp (ssname vps 0))
      (while (not (null vp)) ; walk through VP list,
(ssdel vp vps)
(setq el (entget vp))
(if (/= (cdr (assoc 69 el)) 1) ; look for PSPACE A-Anno-Spce-Nplt,
 (setq lllist "Layout")
) ; and note if found.
(setq vp (ssname vps 0))
      )
    )
  )
  lllist ; Send layout list back to calling routine
)
(princ "\nVPLMAKE loaded. (C)LGCS 2005\n")
(princ)