gile
Swamp Rat
Posts: 797
Marseille, France
Ignore
|
 |
« on: April 02, 2008, 07:06:09 am » |
|
Hi, I can freeze a layer in a viewport by changing the viewport XDatas. ;; VPFREEZE ;; Freeze the layer in the viewport ;; ;; Arguments ;; vp : viewport (vla-object) ;; lay : layer name (string)
(defun vpfreeze (vp lay / typ val) (vla-getXdata vp "ACAD" 'typ 'val) (setq typ (reverse (cons 1002 (cons 1002 (cons 1003 (cddr (reverse (vlax-safearray->list typ)))) ) ) ) val (reverse (cons (vlax-make-variant "}") (cons (vlax-make-variant "}") (cons (vlax-make-variant lay) (cddr (reverse (vlax-safearray->list val))) ) ) ) ) ) (vla-setXData vp (vlax-safearray-fill (vlax-make-safearray vlax-vbInteger (cons 0 (1- (length typ))) ) typ ) (vlax-safearray-fill (vlax-make-safearray vlax-vbVariant (cons 0 (1- (length val))) ) val ) ) ;; this is needed to display the change (vla-display vp :vlax-false) (vla-display vp :vlax-true) ) But how can I thaw a frozen layer in a viewport ? I tried this, but it doesn't work. (defun vpfreeze (vp lay / typ val) (vla-getXdata vp "ACAD" 'typ 'val) (setq typ (reverse (cons 1002 (cons 1002 (cons 1003 (cddr (reverse (vlax-safearray->list typ)))) ) ) ) val (reverse (cons (vlax-make-variant "}") (cons (vlax-make-variant "}") (cons (vlax-make-variant lay) (cddr (reverse (vlax-safearray->list val))) ) ) ) ) ) (vla-setXData vp (vlax-safearray-fill (vlax-make-safearray vlax-vbInteger (cons 0 (1- (length typ))) ) typ ) (vlax-safearray-fill (vlax-make-safearray vlax-vbVariant (cons 0 (1- (length val))) ) val ) ) (vla-display vp :vlax-false) (vla-display vp :vlax-true) )
|
|
|
|
|
Logged
|
Speaking English as a French Frog
|
|
|
CAB
Global Moderator
Needs a day job
Posts: 7520
Ignore
|
 |
« Reply #1 on: April 02, 2008, 07:30:07 am » |
|
As I recall, MP tried to get that to work back in the year 2005 or 2006 and could not so I ended up using (command ".vplayer"
I'll see if I can find the thread for some clues.
|
|
|
|
|
Logged
|
|
|
|
CAB
Global Moderator
Needs a day job
Posts: 7520
Ignore
|
 |
« Reply #2 on: April 02, 2008, 08:35:05 am » |
|
gile, Haven't visited this subject in a long time. Looking at the DXF data for a viewport, the entity name of the frozen layer in in the main entity list. In ACAD 2000 it is in DXF 341 and in ACAD2004 it is in DXF 331. The xdata remains the same. Is the DXF 341 or 331 being updated?
This may be what we missed back in 2005 when we tried to freeze/thaw the VP layers.
I found several threads from that time period but not the one I was looking for. I'd do some testing but I am short of time today.
|
|
|
|
|
Logged
|
|
|
|
Patrick_35
Bull Frog
Posts: 223
Rennes, France
Ignore
|
 |
« Reply #3 on: June 27, 2008, 05:15:25 pm » |
|
Hi I back a topic, but I have the same problem. Unable to frozen a layer in a viewport using xdatas.  If you have found.  @+
|
|
|
|
|
Logged
|
The shape even of the pyramids of Egypt shows that already the workmen tended to make some less and less. Will Cuppy, 1884-1949.
|
|
|
VovKa
Bull Frog
Posts: 359
Ignore
|
 |
« Reply #4 on: June 28, 2008, 06:13:04 am » |
|
the bad thing is that one cannot use the entmod function to modify a viewport entity, making it imposible to remove a 331 group
|
|
|
|
|
Logged
|
|
|
|
Patrick_35
Bull Frog
Posts: 223
Rennes, France
Ignore
|
 |
« Reply #5 on: June 29, 2008, 06:27:25 am » |
|
Yoy can't modify viewport with entmod, but you can with visual.
@+
|
|
|
|
|
Logged
|
The shape even of the pyramids of Egypt shows that already the workmen tended to make some less and less. Will Cuppy, 1884-1949.
|
|
|
CAB
Global Moderator
Needs a day job
Posts: 7520
Ignore
|
 |
« Reply #6 on: June 29, 2008, 03:39:14 pm » |
|
Patrick, Gile's code will FREEZE a layer in a viewport. But no method found to THAW a layer in a viewport. Here is my attempt and it doesn't work.  (defun vpthaw (vp ; vpObject laylist ; list of layer names / typ val TypeList ValueList cFlag pos newlen newtyp newval LayVar ) (vl-load-com) ;; CAB 12/27/2006 ;; (RemoveNth 3 '(0 1 2 3 4 5)) ;; (0 1 2 4 5) (defun removeNth (i lst) (setq i (1+ i)) (vl-remove-if '(lambda (x) (zerop (setq i (1- i)))) lst) )
(vla-getXdata vp "ACAD" 'typ 'val) ; get the xData ;; make xData into 2 lists (setq TypeList (vlax-safearray->list typ) ValueList (vlax-safearray->list val)
)
;; remove the layer names & type data in the list. (foreach Layname layList (if (setq pos (vl-position (setq LayVar (vlax-make-variant layname 8)) valuelist) ) (setq valuelist (vl-remove LayVar valuelist) TypeList (removeNth pos TypeList) cFlag t ) ) )
(if cFlag ; need to update xData (progn (setq newlen (1- (length TypeList)) ;; create new arrays with the new length newtyp (vlax-make-safearray vlax-vbinteger (cons 0 newlen)) newval (vlax-make-safearray vlax-vbvariant (cons 0 newlen)) )
;; fill up the new array with new data (vlax-safearray-fill newtyp TypeList) (vlax-safearray-fill newval ValueList)
;; update the xdata <----<<< NOT working (vlax-invoke-method vp 'SetXData NewTyp NewVal)
(vla-display vp :vlax-false) (vla-display vp :vlax-true)
) ) )
|
|
|
|
« Last Edit: June 29, 2008, 06:49:25 pm by CAB »
|
Logged
|
|
|
|
VovKa
Bull Frog
Posts: 359
Ignore
|
 |
« Reply #7 on: June 29, 2008, 05:08:19 pm » |
|
it seems to me that thawing a layer has nothing to do with xdata
i use a simple method, save a drawing (with frozen layer) in DXF format, then thaw layer and save it again as DXF (with new name). then run some file comparison program, i use standart fc. we'll see than the only difference is presence/absence of 331 group, xdata ramains intact
|
|
|
|
|
Logged
|
|
|
|
CAB
Global Moderator
Needs a day job
Posts: 7520
Ignore
|
 |
« Reply #8 on: June 29, 2008, 06:45:49 pm » |
|
When I freeze a layer the ename is added to the elst 331 and the string name is added to the xData. When I thaw a layer the ename is removed from the elst 331 and the string name is removed from the xData. You can use Gile's code to Freeze a layer which alters the xData and ACAD reactors (I assume) updates the DXF 331. One may conclude that you should be able to reverse the process but it has proven to be incorrect so far.
|
|
|
|
|
Logged
|
|
|
|
Patrick_35
Bull Frog
Posts: 223
Rennes, France
Ignore
|
 |
« Reply #9 on: June 30, 2008, 01:47:08 am » |
|
Thank you for your reply CAB I arrived at the same result that you, namely that the setxdata does not work, despite a safearray correct. I asked to see if someone had not found a trick and circumvented the problem. Apparently not  It is still surprising that we can add, but not delete. The only method is dond use _.vplayer, but when the viewport is not active layout, I do not see how @+
|
|
|
|
|
Logged
|
The shape even of the pyramids of Egypt shows that already the workmen tended to make some less and less. Will Cuppy, 1884-1949.
|
|
|
xycadd
Swamp Rat
Posts: 819
Ignore
|
 |
« Reply #10 on: June 30, 2008, 03:08:25 am » |
|
I remember trying hard on this one as well and in the end also took the (command ".vplayer"...) route. A few years ago, when I was using AutoCAD 2002/2004, I tried Mr. TT's AcadX and I recall it has function(s) to thaw layers in viewport. But AcadX has been discontinued.
|
|
|
|
|
Logged
|
-- C3D 2010 SP1, Windows XP Professional SP3
|
|
|
__declspec
Mega Gator
SuperMod
Needs a day job
Posts: 5795
AKA Daniel
WWW
Ignore
|
 |
« Reply #11 on: June 30, 2008, 03:27:20 am » |
|
|
|
|
|
|
Logged
|
|
|
|
Patrick_35
Bull Frog
Posts: 223
Rennes, France
Ignore
|
 |
« Reply #12 on: June 30, 2008, 06:32:00 am » |
|
Hi I try your arx and it's work to freeze a layout (crpvpfreeze (getvar "clayer") (list (getvar "ctab"))) but don't to thaw (crpvpthaw (getvar "clayer") (list (getvar "ctab"))) I have this error ERREUR INTERNE: !laymgr.cpp@987: eWasopenForRead I load "CrpARX16.arx" in my A2006 (R16.2) @+
|
|
|
|
|
Logged
|
The shape even of the pyramids of Egypt shows that already the workmen tended to make some less and less. Will Cuppy, 1884-1949.
|
|
|
__declspec
Mega Gator
SuperMod
Needs a day job
Posts: 5795
AKA Daniel
WWW
Ignore
|
 |
« Reply #13 on: June 30, 2008, 07:11:40 am » |
|
Doh! I will try to fix it.
Did you try it with a layer that’s not the current layer?
|
|
|
|
|
Logged
|
|
|
|
Patrick_35
Bull Frog
Posts: 223
Rennes, France
Ignore
|
 |
« Reply #14 on: June 30, 2008, 07:50:37 am » |
|
It's the same thing with a layer different from current layer. That would be great, it would indicate the viewport rather than the layout, because you may want to freeze/thaw that the layer on one or several viewports a layout but not necessarily all of a viewports layout. And top tops a list of layers rather than one by one.  @+
|
|
|
|
|
Logged
|
The shape even of the pyramids of Egypt shows that already the workmen tended to make some less and less. Will Cuppy, 1884-1949.
|
|
|
|