Jump to content
WPerciful

change the shade plot

Recommended Posts

WPerciful

I was trying to change the shade plot of a view port by lisp but I didn't see any way to do that through the change properties or through the dxf codes.

 

 

 

(progn
(setq ss1 (ssget "x" '((0 . "VIEWPORT"))))
(command "change" ss1 "" "p")
)

Share this post


Link to post
Share on other sites
Tharwat

Read THIS and go down to DXF 170 :)

Share this post


Link to post
Share on other sites
Tharwat

I guess with vla functions would do the trick since that I also could not get it working with DXF codes .

 

(defun c:test (/ ss in )
 (if (setq ss (ssget "_:L" '((0 . "VIEWPORT"))))
   (repeat (setq in (sslength ss))
     (vla-put-shadeplot
       (vlax-ename->vla-object (ssname ss (setq in (1- in))))
       acShadePlotAsDisplayed
     )
   )
 )
 (princ)
)
(vl-load-com)

Share this post


Link to post
Share on other sites
Lee Mac
I guess with vla functions would do the trick since that I also could not get it working with DXF codes

 

See the third bullet point in this documentation. ;)

Share this post


Link to post
Share on other sites
Tharwat
See the third bullet point in this documentation. ;)

Yeah , that's what I realized after a few tries of ENTMODing a viewport in this thread and another one a few days a go I believe . :thumbsup:

Share this post


Link to post
Share on other sites
WPerciful

Thank you!

Share this post


Link to post
Share on other sites
Dacca_J

Tharwat,

 

I have been playing with the command that you wrote up (very handy by the way), to do something very similar which I have been trying to figure out for a while...

 

Have got it working "partially" & came up with a workaround for the other issues I was having, but you may be able to assist with a solution..?

 

I am trying to:

1 - select all viewports on a given layer (ie "VP_Hidden")

2 - change the shade plot of these viewports to Legacy Hidden

3 (which I can add seperatley) - run print command

 

Your command works when I modify it, but I am wondering what the

"_:L" & the sslength ss does..?

Something to do with finding a length..?

 

I was trying to use this to get around the problem of some viewports reverting back to "as displayed" occasionally...

 

Any help would be appreciated...

Thanks... :)

Share this post


Link to post
Share on other sites
Tharwat

 

"_:L" to avoid selecting objects on Locked layers .

(sslength ss) is the quantity of selection set to be given to Repeat function to run accordingly .

 

 

 

 

(defun c:Test (/ ss in )
 (if (setq ss (ssget "_:L" '((0 . "VIEWPORT")(8 . "VP_Hidden"))))
   (repeat (setq in (sslength ss))
     (vla-put-shadeplot
       (vlax-ename->vla-object (ssname ss (setq in (1- in))))
       acShadePlotHidden
     )
   )
 )
 (princ)
)
(vl-load-com)

Share this post


Link to post
Share on other sites
Lee Mac
I am wondering what the "_:L" & the sslength ss does..?

 

Here is a complete ssget reference detailing all mode strings & filter list operators:

 

ssget function reference

 

Here is a tutorial on selection set processing:

 

Selection Set Processing

 

I hope this helps!

 

Lee

Share this post


Link to post
Share on other sites
jberns

I know this is an old thread, but perhaps someone can offer assistance.

 

In the code above, ShadePlot settings are modified for PaperSpace viewports.

 

Is it possible with code to set ShadePlot = 0 (As displayed) in the Model layout?

 

Thanks,

Jerry

 

Share this post


Link to post
Share on other sites
Roy_043

@jberns Try:

(defun c:test ( / enm)
  (setq elst
    (entget
      (vlax-vla-object->ename
        (vla-get-layout (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
      )
    )
  )
  (entmod
    (subst
      '(76 . 0) ; Gc 76 occurs twice in elst. This will change the 1st occurence.
      (assoc 76 elst)
      elst
    )
  )
  (princ "\nDone! ")
  (princ)
)

 

Edited by Roy_043

Share this post


Link to post
Share on other sites
jberns

@Roy_043,

 

Thanks for the reply and the code. Success!

 

I am curious what was wrong with this code that I was using:

 

;;; Function to get a collection of all layouts in the drawing
(defun LayoutGet (name)
  (dictsearch
    (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT")))
    name
  ) ;_dictsearch
) ;_LayoutGet

(defun C:TEST ( / cmps)
  ;; get Model layout plot info and then store as Current Modelspace Page Setup (cmps)
  (setq cmps (LayoutGet "Model"))
  ;; set Shade Plot (76) to 0 = As Displayed, Shade Plot Resolution (77) to 2 = Normal
  (setq cmps (subst (cons 76 0) (assoc 76 cmps) cmps))
  (setq cmps (subst (cons 77 2) (assoc 77 cmps) cmps))
  ;; Modify and then update the modelspace layout
  (entmod cmps)
  (entupd (cdr (assoc -1 cmps)))
) ;_C:TEST

Executing the 'entmod' line returned the list.

Executing the entupd line returned nil, which failed to update the entity (page setup).

 

Regards,

Jerry

Share this post


Link to post
Share on other sites
Roy_043

I think entupd can only be used for graphical entities. Other than that your code works fine here.

Share this post


Link to post
Share on other sites
jberns

Interesting.

Yes, my posted code 'works' (runs), but the settings in the Plot dialog box are not effected.

I will test again next week, but that was the trouble I encountered. When I made a new named page setup, the shade plot defaulted to legacy wireframe.

When I ran the code, the settings did not change in the PLOT or PAGESETUP dialog box. I was certain the 'entupd' failure was causing the problem.

 

Either way, your code works. Awesome! Thanks again.

 

Kind regards,

Jerry

Share this post


Link to post
Share on other sites
jonathann3891

This one will set all viewports shade plot to hidden, it even works with multiple layouts.

(defun c:test (/)
  (vl-load-com)
  (setq doc (vlax-get-object "AutoCad.Application")
	adoc (vla-get-ActiveDocument doc)
	lao (vla-get-Layouts adoc)
	cnt (vla-get-Count lao)
	inc 0
	)
  (repeat cnt
    (setq cvprt (vla-item lao inc)
	  inc (+ inc 1)
	  blk (vla-get-Block cvprt)
	  )
    (vlax-for itm blk
      (if
	(vlax-property-available-p itm 'ShadePlot)
	(progn
	  (vla-put-ShadePlot itm acShadePlotHidden)
	  (vla-update itm)
	  )
	)
      )
    )
  (princ)
  )

 

Edited by jonathann3891
  • Like 1

Share this post


Link to post
Share on other sites
jberns

Thank you, @jonathann3891.

 

My request was to change the shade plot setting in model space (Model tab), but your code could prove useful for others.

Thank you for sharing. Much appreciated.

 

Kind regards,

Jerry

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×