David Bethel 发表于 2022-7-5 20:15:23

You can try the code in post #9 now.It should be closer.
 
I still really don't see how you replicate your scenario in post 2.   Good luck-David

vernonlee 发表于 2022-7-5 20:18:05

 
David. I just left office. Will see if I can try at home.
 
Not sure if I got you correctly, but Regarding post 2, it was just to illustrate what I mean.From 1 viewport to 4 seperate ones at the same "model view location" but resized to view only 1 specific view each.
 
Thanks for your effort
 
Will post the results after I tried it.
 
Thanks again

vernonlee 发表于 2022-7-5 20:23:02

H David, this is what i got from the updated LISP on post #9
 
 
Pressing Y or N resulted in nothing happening. .
 
Hope you can probe further ,else I do understand & thanks for your effort.

David Bethel 发表于 2022-7-5 20:25:49

 
A locked viewport would lead to an error
 
 
-David

vernonlee 发表于 2022-7-5 20:29:35

 

 
Will try again tomorrow.
 
Thanks David

vernonlee 发表于 2022-7-5 20:31:42

Hi David.
 
This is the results:-
 
- Scale & UCS orientation is same.
- Just that the location of the view is not. As show in the photo below
 

 
 
Also, after running the command once, selecting the original viewport or any viewport (current or newly created) to create another viewport results in this:-
 
Selecting Y or N results in nothing happening

David Bethel 发表于 2022-7-5 20:35:48

Post #9 updated.
 
Unless you have the named views saved, from what I've seen, I don't believe you could totally automate the view process.And even then I doubt the outcome will be exact.-David

vernonlee 发表于 2022-7-5 20:37:22

 
Hi David
 
Thanks. I have tried the updated lisp.
 
It will now allow creating multiple view port without that error.
 
The final issue is that the views still not the same.Buy It's ok. Perhaps it cannot be done.
 
Thanks for the help so far.
 
But I do hope someone out there can solve this issue
 
 
Thanks.

David Bethel 发表于 2022-7-5 20:42:30

Can you post a sample ?

Stefan BMR 发表于 2022-7-5 20:45:26

I've made this one, using a different approach

(vl-load-com)(defun C:CPVP (/ *error* acObj acDoc vp enti p1 p2 enti cen sc newcen dims) (setq acObj (vlax-get-acad-object)       acdoc (vla-get-activedocument acObj)       )(vla-startundomark acDoc)(defun *error* (msg)   (and   msg   (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*BREAK*"))   (princ (strcat "\nError: " msg))   )   (if   (= 8 (logand (getvar 'undoctl) )   (vla-endundomark acDoc)   )   (princ) ) (if   (and   (setq vp (ssget ":E:S:L" '((0 . "VIEWPORT"))))   (setq p1 (getpoint "\nFirst corner: "))   (setq p2 (getcorner p1 "\nSecond corner: "))   )    (progn      (setq p1   (trans p1 1 0)            p2   (trans p2 1 0)            enti   (vla-copy (vlax-ename->vla-object (ssname vp 0)))            sc   (vla-get-CustomScale enti)            newcen (mapcar '(lambda (a b) (/ (+ a b) 2.0)) p1 p2)            dims   (mapcar '- p2 p1)      )      (if (= (vla-get-clipped enti) :vlax-true)      (command "_clip" (vlax-vla-object->ename enti) "_d")      )      (vla-update enti)      (setq cen (vlax-get enti 'center))      (vla-put-mspace acdoc :vlax-true)      (vla-put-activepviewport acdoc enti)      (vla-zoomCenter acObj (vlax-3d-point (trans (trans newcen 3 2) 2 0)) 1)      (vla-put-mspace acdoc :vlax-false)      (vla-put-widthenti (abs (cardims)))      (vla-put-height enti (abs (cadr dims)))      (vla-put-center enti (vlax-3d-point newcen))      (vla-put-CustomScale enti sc)      (command "_move" (vlax-vla-object->ename enti) "" "_non" p1)      (while (> (getvar 'cmdactive) 0)      (command "\\")      )    ) ) (*error* nil) (princ))
页: 1 [2]
查看完整版本: HELP: LISP to create multiple