hi everybody,
I'm trying to make a lisp, in which one I need to zoom to the object.
First and the quickest way for me was whit using zoom command in lisp, but there was a problem.
Zoom object command is not working for me on this drawing.
I founded the way to zoom to the object with out using zoom command in lisp, but it is still pretty annoying for me why command zoom object is not working, is anybody having any ideas?
I have uploaded file in attachements.
Thanks for help.
try to copy to new template file of yours and see what it does and if that fixes it and try to use this.
(defun c:zz() (command"_.zoom" "o" ) (princ) )
Hi,
IMO, if the zoom object fails, it's due to the fact the blocs are inserted far away from origin.
Try using this routine which requires an ename as argument ( i.e. (zoomObject (car (entsel))) )
(defun zoomObject (ent / minPt maxPt) (vl-load-com) (vla-GetBoundingBox (vlax-ename->vla-object ent) 'minPt 'maxpt) (vla-ZoomWindow (vlax-get-acad-object) minPt maxpt) )
Here's another one which works with a selection set.
Using example: (zoomObjects (ssget))
(defun zoomObjects (ss / i minPt maxPt ll ur) (vl-load-com) (repeat (setq i (sslength ss)) (vla-GetBoundingBox (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'minPt 'maxpt ) (setq ll (cons (vlax-safearray->list minPt) ll) ur (cons (vlax-safearray->list maxPt) ur) ) ) (vla-ZoomWindow (vlax-get-acad-object) (vlax-3d-point (apply 'mapcar (cons 'min ll))) (vlax-3d-point (apply 'mapcar (cons 'max ur))) ) )
gile,
Thank you for reply.
Your routines are working fine, on the drawing.
Before this problem, I was using command "zoom" "o" in my routine, I changed to something similar as your code (probably it was your code, which I founded on the web). That was the solution for my problem.
But, I'm having this problem only on this one drawing. I was using same blocks on different drawings for a long time whit out this problem.
So, I was thinking there is probably some kind of system variable which is setting zoom command.
I have founded solution for my problem, but I don't know why is this happening only on this one drawing.
IanGold a écrit :
This is the message appears after running command in cad "too few arguments"
Could you please upload a lisp for other's convenience.
Many Thanks
The upper routines are LISP functions which require an argument.
See the using examples in the messages...
Hi,
What do you mean?
These routines should work whatever the current UCS because both vla-GetBoundingBox and vla-ZoomWindow are related to WCS coordinates, so there's nothing related to the current UCS in these codes.
I think you meant "worked as well when in a view rotated about the UCS". If so, try the following one:
(defun gc:TMatrixFromTo (from to) (append (mapcar (function (lambda (v o) (append (trans v from to T) (list o)) ) ) '((1. 0. 0.) (0. 1. 0.) (0. 0. 1.)) (trans '(0. 0. 0.) to from) ) '((0. 0. 0. 1.)) ) ) (defun zoomObjects (ss / i obj minPt maxPt ll ur) (vl-load-com) (or *acad* (setq *acad* (vlax-get-acad-object))) (or *acdoc* (setq *acdoc* (vla-get-ActiveDocument *acad*))) (setq wcs2ucs (vlax-tmatrix (gc:TMatrixFromTo 0 1)) ucs2wcs (vlax-tmatrix (gc:TMatrixFromTo 1 0)) ) (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vla-TransformBy obj ucs2wcs) (vla-GetBoundingBox obj 'minPt 'maxpt ) (vla-TransformBy obj wcs2ucs) (setq ll (cons (vlax-safearray->list minPt) ll) ur (cons (vlax-safearray->list maxPt) ur) ) ) (vla-ZoomWindow (vlax-get-acad-object) (vlax-3d-point (trans (apply 'mapcar (cons 'min ll)) 1 0)) (vlax-3d-point (trans (apply 'mapcar (cons 'max ur)) 1 0)) ) )