Message 1 of 4
XDATA: Please explain what I've done (Jeff)
Not applicable
08-29-2007
06:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I got this code from one of Jeff M's posts and modified it slightly to give me a list of Viewport IDs and layers frozen in each viewport:
(setq VPF_ss (ssget "X" '((0 . "VIEWPORT")))
VPF_layerlist nil
VPF_count1 0
)
(if VPF_ss
(progn
(while (< VPF_count1 (sslength VPF_ss))
(setq VPF_ent (ssname VPF_ss VPF_count1)
VPF_cont (entget VPF_ent)
VPF_viewportID (cdr (assoc 69 VPF_cont))
)
(vla-GetXData (vlax-ename->vla-object (ssname VPF_ss VPF_count1)) "ACAD" 'VPF_XDataType 'VPF_XDataValue)
(setq VPF_codelist (vlax-safearray->list VPF_XDataType)
VPF_valuelist (vlax-safearray->list VPF_XDataValue)
VPF_templist nil
VPF_count2 0
)
(foreach VPF_nth VPF_codelist
(if (= 1003 VPF_nth)
(setq VPF_templist (append VPF_templist (list (vlax-variant-value (nth VPF_count2 VPF_valuelist)))))
)
(setq VPF_count2 (1+ VPF_count2))
)
(setq VPF_layerlist (append VPF_layerlist (list (cons VPF_viewportID (list VPF_templist)))))
(setq VPF_count1 (1+ VPF_count1))
)
)
)
returns: ((3 ("Layer2" "Layer4")) (2 ("Layer2" "Layer3")) (1 nil))
I staggered about blindly in the original code and managed to come out at the end with the result that I wanted. But how?
The thing that's confusing me is the 1003. I found that this is the layer name, but 1003 doesn't appear in VPF_codelist so how can the foreach statement catch it? Also, where exactly does the code determine that the layer is frozen in the viewport?
Any help on this would be greatly appreciated.
S
(setq VPF_ss (ssget "X" '((0 . "VIEWPORT")))
VPF_layerlist nil
VPF_count1 0
)
(if VPF_ss
(progn
(while (< VPF_count1 (sslength VPF_ss))
(setq VPF_ent (ssname VPF_ss VPF_count1)
VPF_cont (entget VPF_ent)
VPF_viewportID (cdr (assoc 69 VPF_cont))
)
(vla-GetXData (vlax-ename->vla-object (ssname VPF_ss VPF_count1)) "ACAD" 'VPF_XDataType 'VPF_XDataValue)
(setq VPF_codelist (vlax-safearray->list VPF_XDataType)
VPF_valuelist (vlax-safearray->list VPF_XDataValue)
VPF_templist nil
VPF_count2 0
)
(foreach VPF_nth VPF_codelist
(if (= 1003 VPF_nth)
(setq VPF_templist (append VPF_templist (list (vlax-variant-value (nth VPF_count2 VPF_valuelist)))))
)
(setq VPF_count2 (1+ VPF_count2))
)
(setq VPF_layerlist (append VPF_layerlist (list (cons VPF_viewportID (list VPF_templist)))))
(setq VPF_count1 (1+ VPF_count1))
)
)
)
returns: ((3 ("Layer2" "Layer4")) (2 ("Layer2" "Layer3")) (1 nil))
I staggered about blindly in the original code and managed to come out at the end with the result that I wanted. But how?
The thing that's confusing me is the 1003. I found that this is the layer name, but 1003 doesn't appear in VPF_codelist so how can the foreach statement catch it? Also, where exactly does the code determine that the layer is frozen in the viewport?
Any help on this would be greatly appreciated.
S