ketxu Posted November 11, 2011 Share Posted November 11, 2011 Please help me, i've a problem : How to check if entity be viewed in a Viewport ? For Ex, how can i erase , or locked...or do sth.. all viewport that view into a Line ? Srr for my poor English and Thanks all ^^ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2011 Share Posted November 11, 2011 You would need to translate the Viewport Boundary to Modelspace coordinates using the correct transformation matrix based on the scale/twist etc of the viewport (I think gile wrote a function to calculate this matrix), then check whether your objects lie within this point set. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2011 Share Posted November 11, 2011 (I think gile wrote a function to calculate this matrix) Found it: http://www.theswamp.org/index.php?topic=29231.msg347755#msg347755 Quote Link to comment Share on other sites More sharing options...
ketxu Posted November 11, 2011 Author Share Posted November 11, 2011 Thank you very much Lee I try it now ^^ P/s : i'm digging Theswamp and lisp..wow.. how a great data to learn and learn and learn... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2011 Share Posted November 11, 2011 Thank you very much Lee I try it now ^^ You're welcome P/s : i'm digging Theswamp and lisp..wow.. how a great data to learn and learn and learn... TheSwamp is awesome - so many clever guys there. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2011 Share Posted November 11, 2011 As an example for you, this quickly written code will use gile's PCS2WCS function to create an LWPolyline Viewport boundary in Modelspace: (defun c:test ( / _lwvertices _lwpoly cen ent lst vp x ) (defun _lwvertices ( e ) (if (setq e (member (assoc 10 e) e)) (cons (cons (cdr (assoc 10 e)) (assoc 42 e)) (_lwvertices (cdr e))) ) ) (defun _lwpoly ( l ) (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length l)) '(70 . 1) '(410 . "Model") ) (apply 'append l) ) ) ) (if (setq vp (ssget "_+.:E:S" '((0 . "VIEWPORT")))) (progn (setq vp (entget (ssname vp 0))) (if (setq ent (cdr (assoc 340 vp))) (setq lst (_lwvertices (entget ent))) (setq cen (mapcar 'list (cdr (assoc 10 vp)) (list (/ (cdr (assoc 40 vp)) 2.0) (/ (cdr (assoc 41 vp)) 2.0) ) ) lst (mapcar (function (lambda ( a ) (cons (mapcar 'apply a cen) '(42 . 0.0))) ) '((- -) (+ -) (+ +) (- +)) ) ) ) (setq vp (cdr (assoc -1 vp))) (_lwpoly (mapcar '(lambda ( x ) (list (cons 10 (PCS2WCS (car x) vp)) (cdr x))) lst)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
ketxu Posted November 13, 2011 Author Share Posted November 13, 2011 Thank you Lee, it gave me some new funny idea ^^ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 13, 2011 Share Posted November 13, 2011 ......... Quote Link to comment Share on other sites More sharing options...
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.