Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

copy vports command

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
691 Views, 14 Replies

copy vports command

Anyone know how to copy a vieport from one layout in the same dwg to another and yet retain all layer settings etc... for that viewport?
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

Have you tried cut and paste? After the cut and paste, turn the viewport on with mview on. Works for me on 2004. "Andreas Vasiliou" wrote in message news:3fe1a50f$1_2@statler... > Anyone know how to copy a vieport from one layout in the same dwg to another > and yet retain all layer settings etc... for that viewport? > >
Message 3 of 15
Anonymous
in reply to: Anonymous

This method doesn't save the layer status of the viewport. There is a topic in the AUTOCAD2004 group on the very same thing. The only layer which it does save is Layer 0.
May have to try entmake/entmod.

Dean
Message 4 of 15
Anonymous
in reply to: Anonymous

This works for circles, lines etc. but not on vports? (assuming orig ents not on Layout2)

(defun c:xx (/sset ent new_list entdata)
(setq sset (ssget))
(setq ent (ssname sset 0))
(while ent
(setq entdata (entget ent))
(terpri)
(princ(setq new_list (subst (cons 410 "Layout2") (assoc 410 entdata) entdata)))
(terpri)
(entmake new_list)
(ssdel ent sset)
(setq ent (ssname sset 0))

)
)
Message 5 of 15
Anonymous
in reply to: Anonymous

Should have read the help first! :

Notes on Using entmake

You cannot create viewport objects with entmake.

Doh!
Message 6 of 15
Anonymous
in reply to: Anonymous

I have been using that method as well - even as far back as R14 - I would literally make a wblock out of the vport and insert it into another dwg, then explode it (the block) and turn the vport on. Saved layer vis status as far as vplayer type items.
Jeff
Message 7 of 15
Anonymous
in reply to: Anonymous

Have you tried it in 2004? I get the same problem mentioned in the inital post.

Dean
Message was edited by: dean_bourke
Message 8 of 15
Anonymous
in reply to: Anonymous

Thanks guys. The Mview on thing goes some way in helping. It doesn't save the -vplayer settings though. It is to be used in LT so there is no lisp any how. I tried it in LT 2004 as well and same thing. If anyone knows a way of saving the layer states in lisp then this will be handy for when in full acad. Thanks again Andreas "dean_bourke" wrote in message news:25574011.1071800458157.JavaMail.jive@jiveforum1.autodesk.com... > Have you tried it in 2004? > > Dean
Message 9 of 15
Anonymous
in reply to: Anonymous

Andreas, Guess I must have been wrong. I tried it before I posted and it appeared to work. Oh well. It is relatively easy to create a block containing the viewport and then to insert the viewport back into any other layout, explode it, and turn it back on. That will retain the layer settings. I have tested this and it does work in 2004. Regards, Doug "Andreas Vasiliou" wrote in message news:3fe26345_5@statler... > Thanks guys. The Mview on thing goes some way in helping. It doesn't save > the -vplayer settings though. It is to be used in LT so there is no lisp > any how. > > I tried it in LT 2004 as well and same thing. > > If anyone knows a way of saving the layer states in lisp then this will be > handy for when in full acad. > > Thanks again
Message 10 of 15
Anonymous
in reply to: Anonymous

Thanks Doug: Will give that a go. Have a nice and safe festive season. Andreas "Doug Broad" wrote in message news:3fe269eb$1_6@statler... > Andreas, > > Guess I must have been wrong. I tried it before I posted and it appeared > to work. Oh well. It is relatively easy to create a block containing the > viewport and then to insert the viewport back into any other layout, > explode it, and turn it back on. That will retain the layer settings. I have > tested this and it does work in 2004. > > Regards, > Doug > > > > "Andreas Vasiliou" wrote in message news:3fe26345_5@statler... > > Thanks guys. The Mview on thing goes some way in helping. It doesn't save > > the -vplayer settings though. It is to be used in LT so there is no lisp > > any how. > > > > I tried it in LT 2004 as well and same thing. > > > > If anyone knows a way of saving the layer states in lisp then this will be > > handy for when in full acad. > > > > Thanks again > >
Message 11 of 15
Anonymous
in reply to: Anonymous

I just tried it in R2004 LT and doesn't work. Have you been using full Acad? I also have inserted the vport block back into the SAME dwg. Have you done this as well? Let me know. Andreas "Doug Broad" wrote in message news:3fe269eb$1_6@statler... > Andreas, > > Guess I must have been wrong. I tried it before I posted and it appeared > to work. Oh well. It is relatively easy to create a block containing the > viewport and then to insert the viewport back into any other layout, > explode it, and turn it back on. That will retain the layer settings. I have > tested this and it does work in 2004. > > Regards, > Doug > > > > "Andreas Vasiliou" wrote in message news:3fe26345_5@statler... > > Thanks guys. The Mview on thing goes some way in helping. It doesn't save > > the -vplayer settings though. It is to be used in LT so there is no lisp > > any how. > > > > I tried it in LT 2004 as well and same thing. > > > > If anyone knows a way of saving the layer states in lisp then this will be > > handy for when in full acad. > > > > Thanks again > >
Message 12 of 15
Anonymous
in reply to: Anonymous

This doesn't work. Its that same as copy/clip. The viewport is copied, but the layer states are not.
Message 13 of 15
Anonymous
in reply to: Anonymous

This doesn't work. Its that same as copy/clip. The viewport is copied, but the layer states are not.
Message 14 of 15
Anonymous
in reply to: Anonymous

Adreas, I am using AutoCAD 2004 with Architectural Desktop, Service Pack 2 and the toolpalette extension. I have no way of knowing whether this has any effect because I don't have LT. I attach a command log to exlain: (Parenthetical comments) (create the block in layout IIIL) Command: -block Enter block name or [?]: junk Specify insertion base point: 0,0 Select objects: 1 found (a viewport) Select objects: Command: *Cancel* Command: *Cancel* (switch layouts) Command: Regenerating layout. Command: -insert Enter block name or [?]: junk Specify insertion point or [Scale/X/Y/Z/Rotate/PScale/PX/PY/PZ/PRotate]: 0,0 Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: Enter Y scale factor : Specify rotation angle <0>: Command: explode Select objects: 1 found (the junk block) Select objects: Command: mview Specify corner of viewport or [ON/OFF/Fit/Shadeplot/Lock/Object/Polygonal/Restore/2/3/4] : on Select objects: all 111 found 108 were not a viewport. 1 was not in current space. 1 was the paper space viewport. Select objects: Regenerating model. (obtain the xdata for the new viewport) Command: (cdr(assoc -3 (entget(entlast) '("*")))) (("ACAD" (1000 . "MVIEW") (1002 . "{") (1070 . 16) (1010 0.0 0.0 0.0) (1010 0.0 0.0 1.0) (1040 . 0.0) (1040 . 185.419) (1040 . 68.8675) (1040 . -4.69425) (1040 . 50.0) (1040 . 0.0) (1040 . 0.0) (1070 . 0) (1070 . 10000) (1070 . 1) (1070 . 3) (1070 . 0) (1070 . 0) (1070 . 0) (1070 . 0) (1040 . 0.0) (1040 . 0.0) (1040 . 0.0) (1040 . 0.5) (1040 . 0.5) (1040 . 0.5) (1040 . 0.5) (1070 . 0) (1002 . "{") (1003 . "dim") (1002 . "}") (1002 . "}"))) (go back to the previous layout) Command: (here I switch layouts back to original) Regenerating layout. (unerase the old viewport) Command: oops Regenerating model. (obtain the xdata for the old viewport) Command: (cdr(assoc -3 (entget(entlast) '("*")))) (("ACAD" (1000 . "MVIEW") (1002 . "{") (1070 . 16) (1010 0.0 0.0 0.0) (1010 0.0 0.0 1.0) (1040 . 0.0) (1040 . 185.419) (1040 . 68.8675) (1040 . -4.69425) (1040 . 50.0) (1040 . 0.0) (1040 . 0.0) (1070 . 0) (1070 . 10000) (1070 . 1) (1070 . 3) (1070 . 0) (1070 . 0) (1070 . 0) (1070 . 0) (1040 . 0.0) (1040 . 0.0) (1040 . 0.0) (1040 . 0.5) (1040 . 0.5) (1040 . 0.5) (1040 . 0.5) (1070 . 0) (1002 . "{") (1003 . "dim") (1002 . "}") (1002 . "}"))) The results indicate that the new viewport, created in another layout has the same Xdata (layer settings) as the original. I don't know how else to demonstrate this. I also have a program that does this and it works fine. I used -block and -insert because they report on the command line but block and insert also work fine. It is quite possible that LT and ACAD are somehow fundamentally different but this is something I can't test. Sorry it didn't work for you Andreas. Perhaps someone more familiar with LT can help. Regards, Doug "Andreas Vasiliou" wrote in message news:3fe2e951_3@statler... > I just tried it in R2004 LT and doesn't work. Have you been using full > Acad? > > I also have inserted the vport block back into the SAME dwg. Have you done > this as well? > > Let me know. > > Andreas >
Message 15 of 15
cab2k
in reply to: Anonymous

Found this, it copies the layer states which is half to battle.

;; Copy layer states from one viewport to another

(defun copy_vplayer (e1 e2 / old new temp n types values)
(cond
((= (type e1) 'ENAME) (setq e1 (vlax-ename->vla-object e1)))
((= (type e1) 'VLA-Object))
(1 (setq e1 nil))
)
(cond
((= (type e2) 'ENAME) (setq e2 (vlax-ename->vla-object e2)))
((= (type e2) 'VLA-Object))
(1 (setq e2 nil))
)
(and
e1
e2
(= (vla-get-ObjectName e1) (vla-get-ObjectName e2) "AcDbViewport")
(not (vla-getXdata e1 "ACAD" 'types 'values))
(= (type types) 'Safearray)
(= (type values) 'Safearray)
(setq types (vlax-safearray->list types))
(setq values (vlax-safearray->list values))
(setq
old (mapcar (function (lambda (x y) (cons x y))) types values)
)
(setq new (vl-remove-if-not
(function (lambda (x) (= (car x) 1003)))
old
)
)
(setq temp (cons 1002 (vlax-make-variant "}" 8)))
(setq new (append new (list temp temp)))
(not (vla-getXdata e2 "ACAD" 'types 'values))
(= (type types) 'Safearray)
(= (type values) 'Safearray)
(setq types (vlax-safearray->list types))
(setq values (vlax-safearray->list values))
(setq
old (mapcar (function (lambda (x y) (cons x y))) types values)
)
(foreach item (cddr (reverse old))
(if (/= (car item) 1003)
(setq new (cons item new))
)
)
(setq n (1- (length new)))
(setq types (vlax-make-safearray vlax-vbinteger (cons 0 n)))
(vlax-safearray-fill types (mapcar 'car new))
(setq values (vlax-make-safearray vlax-vbvariant (cons 0 n)))
(vlax-safearray-fill values (mapcar 'cdr new))
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'vla-SetXdata
(list e2 types values)
)
)
)
;; Only way I could find to force a regen (other than switching layouts)...
(if (= (vla-get-viewporton e2) :vlax-true)
(progn
(vla-put-viewporton e2 :vlax-false)
(vla-put-viewporton e2 :vlax-true)
T
)
T
)
)
)


(defun c:vpcopy ()

(setq vpFrom (car(entsel "Select VP to copy from.")))
(setq vpTo (car(entsel "Select VP to copy to.")))
(copy_vplayer vpFrom vpTo)
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost