Author Topic: Viewport  (Read 4397 times)

0 Members and 1 Guest are viewing this topic.

Willie

  • Swamp Rat
  • Posts: 958
  • Going nowhere slowly
Viewport
« on: May 28, 2008, 10:17:51 AM »
Why doesn't the following code return nil?  I can not get it to display the alert message when their is no viewports on the layout.

Code: [Select]
(setq SS-VP (ssget "x" (list '(0 . "VIEWPORT") (cons 410 (getvar "ctab")))))
      (if
(= SS-VP nil)
(alert "\n No VIEWPORTS in current layout")

I am trying to create a small routine a help our cad guys to stop putting viewports on the Defpoints layer.
Soli Deo Gloria | Qui Audet Adipiscitur
Windows 8  64-bit Enterprise | Civil 3D 2015 and 2016| ArcGIS 10.1
Yogi Berra : "I'd give my right arm to be ambidextrous."

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport
« Reply #1 on: May 28, 2008, 10:21:26 AM »
Use this:
(if (null SS-VP)


Scratch that.
« Last Edit: May 28, 2008, 10:28:48 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Viewport
« Reply #2 on: May 28, 2008, 10:22:51 AM »
Why not write a button command for it, that sets the correct (desired) layer for the Viewport when they use the button.
Or why not include a viewport on the correct layer for them on the Layout Tab in the Template, so that they can either A) copy and modify the viewport as required, or B) copy the layout tab with the viewport already on it?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Willie

  • Swamp Rat
  • Posts: 958
  • Going nowhere slowly
Re: Viewport
« Reply #3 on: May 28, 2008, 10:35:41 AM »
Why not write a button command for it, that sets the correct (desired) layer for the Viewport when they use the button.
Not a bad idea.  I will give it a try.

Or why not include a viewport on the correct layer for them on the Layout Tab in the Template, so that they can either A) copy and modify the viewport as required, or B) copy the layout tab with the viewport already on it?

Most of the user don't care about using the correct templates or procedures.  With certain projects, they will copy drawings that was done 5 years ago and make a couple of changes and then issue the drawing to the client/contractor.

Part of our problem is that we do not have people that enforces standards or audit the drawings electronicly.  The motto in the office is: If it looks good on paper, it was created in the right way".
Soli Deo Gloria | Qui Audet Adipiscitur
Windows 8  64-bit Enterprise | Civil 3D 2015 and 2016| ArcGIS 10.1
Yogi Berra : "I'd give my right arm to be ambidextrous."

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport
« Reply #4 on: May 28, 2008, 10:36:35 AM »
OK try this:
Code: [Select]
(setq SS-VP (ssget "x" (list '(0 . "VIEWPORT") '(-4 . "/=") '(68 . 1)(cons 410 (getvar "ctab")))))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Willie

  • Swamp Rat
  • Posts: 958
  • Going nowhere slowly
Re: Viewport
« Reply #5 on: May 28, 2008, 10:40:19 AM »
OK try this:
Code: [Select]
(setq SS-VP (ssget "x" (list '(0 . "VIEWPORT") '(-4 . "/=") '(68 . 1)(cons 410 (getvar "ctab")))))

Thanks. It works perfectly.

This realy is the best place on the internet for assistance with code.

Thank you.
Soli Deo Gloria | Qui Audet Adipiscitur
Windows 8  64-bit Enterprise | Civil 3D 2015 and 2016| ArcGIS 10.1
Yogi Berra : "I'd give my right arm to be ambidextrous."

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Viewport
« Reply #6 on: May 28, 2008, 10:49:46 AM »
Glad we could help. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Viewport
« Reply #7 on: May 28, 2008, 11:00:07 AM »

Most of the user don't care about using the correct templates or procedures.  With certain projects, they will copy drawings that was done 5 years ago and make a couple of changes and then issue the drawing to the client/contractor.

Part of our problem is that we do not have people that enforces standards or audit the drawings electronicly.  The motto in the office is: If it looks good on paper, it was created in the right way".

Can we send you some better users to go with that code?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Viewport
« Reply #8 on: May 28, 2008, 11:10:48 AM »
I find the ``flow'' of your three lines interesting.

Create varialble
Test varialbe
Report findings if necessary

Code: [Select]
(setq SS-VP (ssget "x" (list '(0 . "VIEWPORT") '(-4 . "/=") '(68 . 1) (cons 410 (getvar "ctab")))))
(if
  (= SS-VP nil)
  (alert "\n No VIEWPORTS in current layout")
  )

Using an alternate method(s) would be my choice. I think along the lines of something like:

create variable with value of which ever process evaluates to true

Code: [Select]
;; obscure-ish
(setq ss-vp
       (cond
((ssget "x"
(list '(0 . "VIEWPORT")
       '(-4 . "/=")
       '(68 . 1)
       (cons 410 (getvar "ctab")))) )
((alert "\n No VIEWPORTS in current layout"))
         )
   )


do process which evals to true (create the var if necessary--in a sense) ;; <-- that statement is a loaded gun (not really true)!

Code: [Select]
;; straight forward-ish
(cond
  ((setq ss-vp
         (ssget "x"
                (list '(0 . "VIEWPORT")
                      '(-4 . "/=")
                      '(68 . 1)
                      (cons 410 (getvar "ctab"))))) )
  ((alert "\n No VIEWPORTS in current layout"))
 )

...I think its kinda fun to try and glean how people process problems from small bits of code
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Viewport
« Reply #9 on: May 28, 2008, 11:52:45 AM »
Another way :)

Code: [Select]
(or (ssget "x"
   (list '(0 . "VIEWPORT")
'(-4 . "/=")
'(68 . 1)
(cons 410 (getvar 'ctab))
   )
    )
    (alert "\n No VIEWPORTS in current layout")
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Viewport
« Reply #10 on: May 28, 2008, 11:57:47 AM »
Another way :)


And the variable? ;p
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Viewport
« Reply #11 on: May 28, 2008, 12:00:26 PM »
What variable? :-P

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Viewport
« Reply #12 on: May 28, 2008, 12:04:11 PM »
Did you think the sole purpose of the application was to create a selection set of a view port in paper space or do you think it more likely some other process' might take place on the selection set?

;P


*lmao*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Viewport
« Reply #13 on: May 28, 2008, 12:10:58 PM »
Picky picky  :-D

Code: [Select]
(or (setq vp-ss (ssget "x"
       (list '(0 . "VIEWPORT")
     '(-4 . "/=")
     '(68 . 1)
     (cons 410 (getvar 'ctab))
       )
)
    )
    (alert "\n No VIEWPORTS in current layout")
)
« Last Edit: May 28, 2008, 12:17:16 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Viewport
« Reply #14 on: May 28, 2008, 12:24:49 PM »
command reactor . . ..
James Buzbee
Windows 8