Getting a Viewports Layerstatename

Getting a Viewports Layerstatename

GeeHaa
Collaborator Collaborator
654 Views
4 Replies
Message 1 of 5

Getting a Viewports Layerstatename

GeeHaa
Collaborator
Collaborator

Hi 

 

Once that a viewport has a been assigned a layerstate is there aby way to find out what the layerstatename is for that particular viewport?

 

Thanks in advance

0 Likes
655 Views
4 Replies
Replies (4)
Message 2 of 5

CodeDing
Advisor
Advisor

@GeeHaa ,

 

I'm glad you asked this question, I learned some things. Turns out there are "layerstate-" functions for autoLISP.

Here's a quick snip that should get you on track:

(defun c:VPLS ( / lsName vp ls)
;ViewPort LayerState
(setq lsName nil vp (car (entsel "\nSelect Viewport: ")))
(foreach ls (layerstate-getnames)
  (if (layerstate-compare ls vp) (setq lsName ls))
);foreach
(if lsName
  (prompt (strcat "\nLayer state for selected viewport: " lsName))
  (prompt "\nNo layer state found for this viewport...")
);if
(princ)
);defun

Best,

~DD

Message 3 of 5

GeeHaa
Collaborator
Collaborator

Thanks for the response and you gave me exactly what I asked for. Unfortunately  I need it to update existing viewports with modified layerstate data so comparing the LayerStates' data with the  viewports' layerstate data won't work because the  new layerstates don't match the old ones in the existing viewports. I guess that's why they don't update automatically in the first place. If there is no other way I guess I will have to write something  that assigns the layerstate to the viewport using layerstate-restore then add more xdata (layerstatename) to the viewport for later use in updating them.

 

Thanks Again.

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant

Can't you simply use layers of a viewport (frame) to differentiate which layer state is the vp assigned?

0 Likes
Message 5 of 5

GeeHaa
Collaborator
Collaborator

Not if the new (updated)layerstate with the same name has different layer assignments than the old one that was used to set the layers in the viewport the first time.

0 Likes