hmsilva Posted May 31, 2014 Posted May 31, 2014 Hi Saqib_thelo, the BoundingBox is always calculated in WCS... To use the same method in UCS I have recurred to two Gilles Chanteau's excellent functions, the gc:TMatrixFromTo and gc:UcsBoundingBox. (defun c:demo ( / a b e) (vl-load-com) ;; by Gilles Chanteau ;; gc:TMatrixFromTo ;; Retourne la matrice de transformation (4x4) d'un système de coordonnées ;; vers un autre (mêmes types d'arguments que trans) ;; ;; Arguments ;; from : système de coordonnées de départ (entier, vecteur ou ename) ;; to : système de coordonnées de destination (entier, vecteur ou ename) (defun gc:TMatrixFromTo (from to) (append (mapcar (function (lambda (v o) (append (trans v from to T) (list o)) ) ) (list '(1. 0. 0.) '(0. 1. 0.) '(0. 0. 1.)) (trans '(0 0 0) to from) ) (list '(0. 0. 0. 1.)) ) ) ;; by Gilles Chanteau ;; gc:UcsBoundingBox ;; Retourne les coordonnées SCU de l'emprise (bounding box) de l'entité ;; par rapport au SCU courant. ;; ;; Arguments ;; obj: une entité (ENAME ou VLA-OBJCET) ;; _OutputMinPtSym: un symbole quoté (output) ;; _OutputMaxPtSym: un symbole quoté (output) (defun gc:UcsBoundingBox (obj _OutputMinPtSym _OutputMaxPtSym) (vl-load-com) (and (= (type obj) 'ENAME) (setq obj (vlax-ename->vla-object obj)) ) (vla-TransformBy obj (vlax-tmatrix (gc:TMatrixFromTo 1 0))) (vla-GetBoundingBox obj _OutputMinPtSym _OutputMaxPtSym) (vla-TransformBy obj (vlax-tmatrix (gc:TMatrixFromTo 0 1))) (set _OutputMinPtSym (vlax-safearray->list (eval _OutputMinPtSym)) ) (set _OutputMaxPtSym (vlax-safearray->list (eval _OutputMaxPtSym)) ) ) (if (setq e (car (entsel "\nSelect Rectang : "))) (progn (gc:UcsBoundingBox e 'a 'b) (vl-cmdf "_.zoom" a b) ) ) (princ) ) Without using the BoundingBox method, maybe something like this will be enough (defun c:demo (/ a b o ss) (vl-load-com) (if (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE")(-4 . "&=")(70 . 1)))) (progn (setq o (vlax-ename->vla-object (ssname ss 0)) a (vlax-curve-getpointatparam o 1) b (vlax-curve-getpointatparam o 3) ) (vl-cmdf "_.zoom" (trans a 0 1) (trans b 0 1)) ) ) (princ) ) Hope that helps Henrique Quote
Saqib_theleo Posted June 1, 2014 Author Posted June 1, 2014 Hi Henrique, Many thankss. Both codes are working nice on changed UCS. Thanks for you time and help. GBY. Quote
hmsilva Posted June 1, 2014 Posted June 1, 2014 You're welcome, Saqib_thelo Glad I could help Henrique Quote
EBROWN Posted June 4, 2014 Posted June 4, 2014 Thank you Henrique. Using the first program I can select a polyline or block. Using the second program I can not select the block only a polyline. I have tried to add the step to lock the viewport but failed. Could you add that step to the programS. Thanks EBROWN Quote
EBROWN Posted June 4, 2014 Posted June 4, 2014 Henrique, I gave it one more try and I was able to add the step to lock the viewport. Thanks EBROWN Quote
janaudie Posted March 10, 2020 Posted March 10, 2020 It says this error Select Rectang : ; error: no function definition: VLAX-ENAME->VLA-OBJECT How to fix this? Quote
ronjonp Posted March 10, 2020 Posted March 10, 2020 6 hours ago, janaudie said: It says this error Select Rectang : ; error: no function definition: VLAX-ENAME->VLA-OBJECT How to fix this? Add (VL-LOAD-COM) to the code. Quote
janaudie Posted March 12, 2020 Posted March 12, 2020 I added the (vl-load-com) but still the same error. Quote
janaudie Posted March 16, 2020 Posted March 16, 2020 On 10/03/2020 at 22:28, janaudie said: It says this error Select Rectang : ; error: no function definition: VLAX-ENAME->VLA-OBJECT How to fix this? Any update for this error? it's the same error when (vl-load-com) will be added. sorry I'm not expert on lisps Quote
BIGAL Posted March 16, 2020 Posted March 16, 2020 Did you add it as 1st line after the defun line ? Quote
sivapathasunderam Posted March 7, 2023 Posted March 7, 2023 On 4/18/2014 at 7:56 PM, hmsilva said: Hi EBROWN, (defun c:demo (/ a b e o) (vl-load-com) (if (and (= (getvar 'TILEMODE) 0) (/= (getvar 'CVPORT) 1) (setq e (car (entsel "\nSelect Rectang : "))) ) (progn (setq o (vlax-ename->vla-object e)) (vlax-invoke-method o 'GetBoundingBox 'a 'b) (setq a (vlax-safearray->list a) b (vlax-safearray->list b) ) (vl-cmdf "_.zoom" a b) (vlax-put (vla-get-activepviewport (vla-get-activedocument (vlax-get-acad-object)) ) 'DisplayLocked :vlax-true ) ) ) (princ) ) HTH Henrique I want to add when you select the viewport if it is Locked remove it ! (defun SSVPLock ( ss lock / i ) (if ss (repeat (setq i (sslength ss)) (vla-put-displaylocked (vlax-ename->vla-object (ssname ss (setq i (1- i)))) lock) t ) )) ;;Unlocks Selected Viewports / Requires a pick (if (SSVPLock (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))) :vlax-false) (princ "\n--> Viewport Unlocked.")) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.