XDATA: Please explain what I've done (Jeff)

XDATA: Please explain what I've done (Jeff)

Anonymous
Not applicable
211 Views
3 Replies
Message 1 of 4

XDATA: Please explain what I've done (Jeff)

Anonymous
Not applicable
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
0 Likes
212 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi,

Only then when there is a frozen layer in the viewport the code 1003 will be present.

The paperspace viewport (mostly Viewport 1) has in this case no frozen layers

i have modified your code that there is no frozen layers it's not in the VPF_layerlist

(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)
)
(if (setq VPF_templist (vl-remove nil (mapcar '(lambda(x y)(if (= 1003 x)(vlax-variant-value y))) VPF_codelist VPF_valuelist)))
(setq VPF_layerlist (append VPF_layerlist (list (cons VPF_viewportID (list VPF_templist)))))
)
(setq VPF_count1 (1+ VPF_count1))
)
)
)
Cheers
Harrie
0 Likes
Message 3 of 4

Anonymous
Not applicable
Scott,
As Harrie points out, the 1003 code will only be present if there are layers
frozen in the Viewport, which is why the first VP returns nil, since it is
the View of the Paperspace Layout.

Here's a quick dump of a VP object using (entget) so you can see that the
data is there. Note the 1003 Groups near the end. These are the layers
frozen in that VP. HTH.

Command: (entget (car (entsel)) '("ACAD"))

Select object: ((-1 . ) (0 . "VIEWPORT") (330 .

name: 40083cc8>) (5 . "77C2BFCE2783B58C") (100 . "AcDbEntity") (67 . 1) (410
..
"Layout1") (8 . "VPORTS") (100 . "AcDbViewport") (10 17.5964 12.1314 0.0)
(40 .
30.4121) (41 . 21.5926) (68 . 2) (69 . 2) (12 10948.4 3972.6 0.0) (13 0.0
0.0
0.0) (14 5.0 5.0 0.0) (15 5.0 5.0 0.0) (16 0.0 0.0 1.0) (17 0.0 0.0 0.0) (42
..
50.0) (43 . 0.0) (44 . 0.0) (45 . 431.851) (50 . 0.0) (51 . 0.0) (72 .
10000)
(341 . ) (341 . ) (90 . 49152)
(281 . 0) (71 . 1) (74 . 0) (110 0.0 0.0 0.0) (111 1.0 0.0 0.0) (112 0.0 1.0
0.0) (79 . 0) (146 . 0.0) (-3 ("ACAD" (1000 . "MVIEW") (1002 . "{") (1070 .
16)
(1010 0.0 0.0 0.0) (1010 0.0 0.0 1.0) (1040 . 0.0) (1040 . 431.851) (1040 .
10948.4) (1040 . 3972.6) (1040 . 50.0) (1040 . 0.0) (1040 . 0.0) (1070 . 0)
(1070 . 10000) (1070 . 1) (1070 . 0) (1070 . 0) (1070 . 0) (1070 . 0) (1070
..
0) (1040 . 0.0) (1040 . 0.0) (1040 . 0.0) (1040 . 5.0) (1040 . 5.0) (1040 .
5.0) (1040 . 5.0) (1070 . 0) (1002 . "{") (1003 . "EX-LIP") (1003 .
"EX-ELEC")
(1002 . "}") (1002 . "}"))))

wrote in message news:5705296@discussion.autodesk.com...
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:
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
0 Likes
Message 4 of 4

Anonymous
Not applicable
Harrie & Jeff,

Thanks for your responses. It makes sense to me now. I've just found the Extended Data section in the help file (DXF > Advanced DXF) and see that 1003 is listed as 'layer associated with the ex. data'.

I've still a lot to learn regarding XDATA, but at least my eyes are a little more open now.

Regards,

S
0 Likes