HELP: LISP to create multiple
One of my routine work is to highlight only part view of a drawing that has changes, to our consultants.This involves creating individual viewports, of a specific view, out of that drawing (which could have 1 or more viewports).
I normally copy the existing viewport (no. of times will depend on the no. of views i need). Then i would pick 1corner of 1 of the copied vport & stretch it to the area concern, then stretch the other thereby resizing that copied vport to show a certain view of the drawing only.
I then repeat this process depending on the no. of changes.
If it would be possible, can someone advise on a lisp that can create the same viewport (using it as a base) (following the same UCS/layers that are on/off/frozen/thaw/lock/unlock) & with 3 clicks ( 1 click to select existing viewport, 2nd & 3rd click to create the 2 window corners for the new view port.
That would shorten my work time considerably.
Thanks Attached is a picture explaining what i mean. Hope that would be clearer.
Please also note the following:-
- the viewport's view UCS is at an angle (meaning rotated) , as the drawing in modelspace is at an angle
- all are existing drawings (created 2 years ago)
While you cannot use( entmake ) or ( entmod ) on a viewport entity, you can access the data and xdata via ( entget ).
This is a STARTING POINT ONLY !
(defun c:cvp (/ en ss p1 p2 ed xd l1010 l1040 l1070 l1003 vtar vdir vtws vhgt vcxa vcya vlen vscl id) (setvar "TILEMODE" 0) (command "_.PSPACE") (while (not en) (and (setq ss (ssget '((0 . "VIEWPORT")))) (= (sslength ss) 1) (setq en (ssname ss 0)))) (initget 1) (setq p1 (getpoint "\n1st Corner: ")) (initget 1) (setq p2 (getcorner p1 "\nOpposite Corner: ")) (setq ed (entget en '("ACAD"))) (setq xd (cdr (cadr (assoc -3 ed)))) (setq l1003 nil l1040 nil l1010 nil l1070 nil) (foreach l xd (cond ((= (car l) 1010) (setq l1010 (cons (cdr l) l1010))) ((= (car l) 1040) (setq l1040 (cons (cdr l) l1040))) ((= (car l) 1070) (setq l1070 (cons (cdr l) l1070))) ((= (car l) 1003) (setq l1003 (cons (cdr l) l1003))))) (setq l1010 (reverse l1010)) (setq l1040 (reverse l1040)) (setq l1070 (reverse l1070)) (setq l1003 (reverse l1003));;;VIEW POINTS (setq vtar (nth 0 l1010)) (setq vdir (nth 1 l1010)) (setq vtws (nth 0 l1040)) (setq vhgt (nth 1 l1040)) (setq vcxa (nth 2 l1040)) (setq vcya (nth 3 l1040)) (setq vlen (nth 4 l1040)) (setq vscl (/ vhgt (cdr (assoc 41 ed))));;;MAKE A NEW VIEWPORT (command "_.MVIEW" p1 p2) (setq id (cdr (assoc 69 (entget (entlast)))));;;SET FREEZE LAYERS (command "_.VPLAYER") (foreach l l1003 (command "_Freeze" l "_Select" "_Last" "")) (command "");;;SET VIEW (command "_.MSPACE") (command "_.ZOOM" "_C" (list vcxa vcya) vscl) (command "_.VPOINT" vdir "") (command "_.DVIEW" "_All" "" "_TArget" vtar "") (command "_.PSPACE")(prin1))
Figuring out the view info and ucs would take some trail and error
Can you post flow chart of all of the command sequences that you currently use ?
-David Hi David
Thanks for the reply.
I just left office & on the way home when I saw your reply.Will try it tomorrow when I am back in office. I will also post all the command as requested.
Thanks Now that I see you sample, I doubt that it is possible to automate that process.-David
Tried out the lisp.
The steps & intention seems to be what i wanted (within 3 clicks)but the result of the newly created viewport is not the same view as the original viewport. Also, the view is showing the "Z" view. So i am seeing only 1 straight line
This is the steps of how i normally do.
Basically each view i will need to create 3 viewports.1 for the drawing itself.
1 for the X axis grid line
1 for the Y axis grid line
Hope to find a possible solution.
Just to clarify, i do not mean 3 clicks to get 4 viewports out of that 1 existing viewport.
More like 3 clicks to get 1 viewport would be out of this world for me. Alternatively, is there a way to match new viewports (excatly the same) to the original viewport?
I tried that but the inside view is not in the same location & the drawing view was tilted This is totally (command ) grunt work, but maybe useful :
(defun c:cvp (/ oc oe en ss p1 p2 ed xd l1003 id vc oy vs vy vd) (setq oc (getvar "CMDECHO") oe (getvar "EXPERT")) (command "_.CMDECHO" 1) (command "_.TILEMODE" 0) (command "_.EXPERT" 5) (command "_.PSPACE") (command "_.MVIEW" "_Lock" "_Off" "_All" "") (while (not en) (princ "\nSelect Main Viewport") (and (setq ss (ssget '((0 . "VIEWPORT")))) (= (sslength ss) 1) (setq en (ssname ss 0)))) (initget 1) (setq p1 (getpoint "\n1st Corner: ")) (initget 1) (setq p2 (getcorner p1 "\nOpposite Corner: ")) (setq ed (entget en '("ACAD"))) (setq xd (cdr (cadr (assoc -3 ed)))) (setq l1003 nil) (foreach l xd (cond ((= (car l) 1003) (setq l1003 (cons (cdr l) l1003))))) (setq id (cdr (assoc 69 ed))) (command "_.MSPACE") (command "_.CVPORT" id) (command "_.VIEW" "_Save" "CVP") (command "_.UCS""_Save" "CVP") (setq vc (getvar "VIEWCTR") oy (cdr (assoc 41 ed)) vs (getvar "VIEWSIZE")) (command "_.PSPACE");;;MAKE A NEW VIEWPORT (command "_.MVIEW" p1 p2 "_.CHPROP" (entlast) "" "_LA" (cdr (assoc 8 ed)) "_C" (if (assoc 62 ed) (cdr (assoc 62 ed)) "BYLAYER") "") (setq vd (entget (entlast)) vy (cdr (assoc 41 vd)) id (cdr (assoc 69 vd))) (command "_.VPLAYER") (foreach l l1003 (command "_Freeze" l "_Select" "_Last" "")) (command "");;;SET VIEW & UCS (command "_.MSPACE") (command "_.CVPORT" id) (command "_.VIEW" "_Restore" "CVP") (command "_.UCS""_Restore" "CVP") (command "_.ZOOM" "_C" vc (* vy (/ vs oy))) (command "_.PSPACE") (command "_.EXPERT" oe) (command "_.CMDECHO" oc)(prin1))
-David
Hi David,
I am still in office so tested it.
the result was it matches the ucs (meaning the drawing is now right side up which is correct) however the scale & the view is different from the original.
页:
[1]
2