Author Topic: Script to move viewports off DEFPOINTS to a specified layer.  (Read 1803 times)

0 Members and 1 Guest are viewing this topic.

DIW_CADtech

  • Bull Frog
  • Posts: 368
  • Push limits, embrace success, & discard failure.
Peers,

I have approximately 700 DWGs, that need to be... fixed.. for some reason the viewports are printing hairline thick lines on the plotted pdf.  Sometimes just the top line of the Vport, sometimes the left or the right, and sometimes the right and the bottom.. etc...  I have noticed that if I transfer the Vports from the Defpoints layer to a "NoPlot" layer with the NoPlot setting checked, I don't get the hairlines in the PDF, or the plot.

( yes Defpoints is a no plot layer, but for some reason.. it's plotting )

Does someone on TheSwamp.org have a script to move all viewports to a specified layer..  in this case "NoPlot"?

I'm working off a less than speedy server so manually updating these is not going to happen.  I was planning on possibly running a script  on Script pro as I exit the building.. and checking it in the morning. 

I am very  trainable....   (forgive my spelling)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Script to move viewports off DEFPOINTS to a specified layer.
« Reply #1 on: July 02, 2014, 07:44:29 PM »
This is what I have been using on single drawings:
Code: [Select]
;;  05.03.07
;;  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
;;  force vp's to layer  "Viewport Borders"
;;  ignore vp's on layer "vpPlot"     
;;  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
(defun c:vp2LayAll () (vp2lay ""))
(defun vp2lay (tabname / lay obj targetobj rtnflag)
  (vl-load-com)
 
;;  CAB version to make a layer
;;  returns nil if make failed
(defun MakeLayer (lyrname acDoc / lyrobj)
  (vl-load-com)
  (if
    (not
      (vl-catch-all-error-p
        (setq lyrobj (vl-catch-all-apply 'vla-add (list (vla-get-layers acDoc) lyrname))))
    )
    lyrobj
  )
)


 
  (if (null color) ; use default (defined in Globle variable) colors
    (setq color (if lockflag *vpColorLk *vpColorUnLk))
  )

  ;;  A spicific tab name can be used to work in one Layout only
  (or (= (type tabname) 'STR) (setq tabname "")) ; default to ALL
  (if (= tabname "Model")
    (progn (alert "Not allowed in Model Space") (quit))
  )
 
  ;; make Layer "Viewport Borders" color=12  NoPlot
  ;;  try to rename first!
  (setq vpLayer "Viewport Borders")
  (if (and (not (tblsearch "layer" vpLayer))
        (setq lyrobj (MakeLayer vpLayer (vla-get-activedocument (vlax-get-acad-object))
       )))
    (progn
      (vla-put-color lyrobj 12)
      (vla-put-plottable lyrobj :vlax-false)
      (vlax-release-object lyrobj)
    )
   )


  ;;  step through each Layout and step through each object in the layout
  ;;  if object is a VP and the layer is NOT VPPLOT change the layer to "Viewport Borders"
  ;;  if the VP has a non rectangle shape change the pline outline layer associated with the VP
  (vlax-for lay (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) ; for each layout
    (if (and (or (= tabname "")
                 (= (vla-get-name lay) tabname))
             (eq :vlax-false (vla-get-modeltype lay)))
      (vlax-for obj (vla-get-block lay) ; for each obj in layout
        (if (and (= (vla-get-objectname obj) "AcDbViewport")
                 (or (null targetobj) (equal obj targetobj))
            )
         (if (/= (strcase (vla-get-layer obj)) "VPPLOT")
          (progn
            (vla-put-layer obj vpLayer)
            (if (setq ent (assoc 340 (entget (vlax-vla-object->ename obj))))
              (vla-put-layer (vlax-ename->vla-object (cdr ent)) vpLayer)
            )
            (setq rtnflag t)
          ))
        )
      )
    )
  )
  rtnflag
)
« Last Edit: July 03, 2014, 09:00: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.

DIW_CADtech

  • Bull Frog
  • Posts: 368
  • Push limits, embrace success, & discard failure.
Re: Script to move viewports off DEFPOINTS to a specified layer.
« Reply #2 on: July 02, 2014, 10:26:47 PM »
As it turns out, the vp was directly on top of a rectangle on a titleblock layer. and that was the issue...  HOWEVER.  your code rocks!  and I'll be using that as welll. VERY VERY COOL

I could script that and set viewports on a whole directory of dwgs in like no time flat..

I'm working with a municipality that is holding me to their CAD standards, but won't share the complete CAD standards manual with me.  It's bizzar.

And they keep flip flopping on issues.  Driving me nutz.   :realmad:
I am very  trainable....   (forgive my spelling)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Script to move viewports off DEFPOINTS to a specified layer.
« Reply #3 on: July 02, 2014, 11:02:36 PM »
Glad to help.
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.

DIW_CADtech

  • Bull Frog
  • Posts: 368
  • Push limits, embrace success, & discard failure.
Re: Script to move viewports off DEFPOINTS to a specified layer.
« Reply #4 on: July 02, 2014, 11:03:17 PM »
Love this .org..
truely my fav.
get the best help here.
I am very  trainable....   (forgive my spelling)

DIW_CADtech

  • Bull Frog
  • Posts: 368
  • Push limits, embrace success, & discard failure.
Re: Script to move viewports off DEFPOINTS to a specified layer.
« Reply #5 on: July 02, 2014, 11:07:09 PM »
Testing this out..
Read your code.. set the color to 256.. and layer settings to NOPLOT and to Skip Vp's on layer XXXXXX
and changed the the create layer color to 7 (white)


I just used the Replace tool in notepad to accomplish this..

Awesome...
only thing better would be to understand the code.

Thank you very much.. it's wroking great!

I am very  trainable....   (forgive my spelling)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Script to move viewports off DEFPOINTS to a specified layer.
« Reply #6 on: July 03, 2014, 09:01:43 AM »
I added some text to the code for some explanations, not all.
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.