blueshake Posted October 31, 2010 Posted October 31, 2010 hi,all the following codes are used to copy objects subjected to a circle user defined. here comes my issue.see the pictures. the blue ones are copied from the while, the green circle is a user defined zone.now I only want to trim the blue ones.not the green lines.how I can do this? thank you for your time to read this. (defun c:tt(/) (setq pt (getpoint "\nget the center point.")) (command "_.circle" pt) (princ (strcat "\ninput the radius of circle")) (command pause "") (setq cir (entlast)) (setq r (cdr (assoc 40 (entget cir)))) (command "copy" "cp") (setq n 0) (repeat 180 (command (polar pt (/(* 2 n pi)180) r)) (setq n (+ n 1)) ) (command "" "" pt (getpoint));ok ,finish the choose and copy ;now how to get copied objects. and trim the things outside the circle. ;here I just want to trim the copied objects. ) Quote
David Bethel Posted October 31, 2010 Posted October 31, 2010 If you're not using a TRIM command, kind of old, but this could be a starting point: ;;;Intersection Point Of LINE & CIRCLE ;;;ARG -> LINE ename CIRCLE ename ;;;RETURNS 2D point list or nil (defun inters_line_circle (le ce / p10 p11 cen rad ppt pds osd ipt p2d) (setq p2d (lambda (p) (list (car p) (cadr p)))) (and (= (type le) 'ENAME) (= (type ce) 'ENAME) (= "LINE" (cdr (assoc 0 (entget le)))) (= "CIRCLE" (cdr (assoc 0 (entget ce)))) (setq p10 (p2d (cdr (assoc 10 (entget le)))) p11 (p2d (cdr (assoc 11 (entget le)))) cen (p2d (cdr (assoc 10 (entget ce)))) rad (cdr (assoc 40 (entget ce)))) (cond ((equal p10 p11 1e-14)) ((equal rad (distance cen p10) 1e-11) (setq ipt p10)) ((equal rad (distance cen p11) 1e-11) (setq ipt p11)) ((setq ppt (inters p10 p11 cen (polar cen (+ (angle p10 p11) (* pi 0.5)) rad) nil)) (and (setq pds (distance cen ppt)) (<= pds rad) (setq osd (sqrt (- (* rad rad) (* pds pds))) ipt (polar ppt (angle ppt p10) osd)))))) ipt) Quote
blueshake Posted October 31, 2010 Author Posted October 31, 2010 @David I dig into your codes, and found that it only work for lines. Actually I want to write a detail view lisp.in this lisp ,we should copy the objects surround by the circle user provide and trim the things beyond the circle. Quote
blueshake Posted October 31, 2010 Author Posted October 31, 2010 hi,Lee I put "extrim" in cad help documents and it said it is unknown command.maybe it is "trim"?? I want to write a detail view lisp.do you have any idea about this??? Quote
Lee Mac Posted October 31, 2010 Posted October 31, 2010 I put "extrim" in cad help documents and it said it is unknown command.maybe it is "trim"?? It is an Express Tools function Quote
blueshake Posted November 1, 2010 Author Posted November 1, 2010 after much try.here comes another codes. but it trim everything beyond the circle.how can I just trim the copied ones. (defun c:tt(/) (defun *error* (msg) (setvar "osmode" oldOsmode) ) (setq oldOsmode (getvar "osmode")) (setvar "OSMODE" 0) (setq pt (getpoint "\nget the center point.")) (command "_.circle" pt) (princ (strcat "\ninput the radius of circle")) (command pause "") (setq cir (entlast)) (setq r (cdr (assoc 40 (entget cir)))) (command "copy" "cp") (setq n 0) (repeat 180 (command (polar pt (/ (* 2 n pi) 180) r)) (setq n (+ n 1)) ) (command "" "" pt pt) (setvar "pickbox" 5) (command "_.trim" cir "" "f") (setq n 0) (repeat 180 (command (polar pt (* (/ (* 2 n) 180.0) pi) (* r 1.05))) (setq n (1+ n)) ) (command "" "") ;(command "" "" pt (setq ptt (getpoint pt)));ok ,finish the choose and copy ;now how to get copied objects. and trim the things outside the circle. ;here I just want to trim the copied objects. ) Quote
Tharwat Posted November 1, 2010 Posted November 1, 2010 I am not sure of your request, but this may help you or approach the image to you . (defun c:tt (/ pt rad cir all) (command "_.circle" (setq pt (getpoint "\n Specify the center point.")) (setq rad (getdist pt "\n Get Circle Diameter .")) ) (setq cir (entlast) ) (princ "\n Select objects to be trimed") (setq all (ssget "_x" '((0 . "SPLINE,LWPOLYLINE,POLYLINE,LINE,CIRCLE")))) (repeat (sslength all) (command "_.trim" cir "" all "") ) (princ) ) Tharwat Quote
alanjt Posted November 1, 2010 Posted November 1, 2010 Crude example, but should help you with the trimming part. (defun c:Test (/ lastEntity pt ent) (setq lastEntity (entlast)) (if (or etrim (load "extrim.lsp" nil)) (if (setq pt (getpoint "\nSpecify center point for circle: ")) (progn (command "_.circle" "_non" pt) (while (eq 1 (logand 1 (getvar 'cmdactive))) (command PAUSE)) (or (eq lastEntity (setq ent (entlast))) (etrim ent (polar (cdr (assoc 10 (entget ent))) 0. (1+ (cdr (assoc 40 (entget ent)))))) ) ) ) (alert "Express Tool \"Extrim\" does not exist!") ) (princ) ) Quote
blueshake Posted November 5, 2010 Author Posted November 5, 2010 hi,all I finally finish the program. here are the codes. (defun c:tt(/) (defun *error* (msg) (setvar "osmode" oldOsmode) ) (setq oldOsmode (getvar "osmode")) (setvar "OSMODE" 0) (setq pt (getpoint "\nget the center point.")) (command "_.circle" pt) (princ (strcat "\ninput the radius of circle")) (command pause "") (setq cir (entlast)) (setq r (cdr (assoc 40 (entget cir)))) ;(command "_.circle" pt 2*r "") (setq enlargeCircle (entlast)) (command "_.move" enlargeCircle "" pt (setq ptt (getpoint pt))) (command "copy" "cp") (setq n 0) (repeat 180 (command (polar pt (/ (* 2 n pi) 180) r)) (setq n (+ n 1)) ) (command "" "" pt ptt) (setvar "pickbox" 5) (command "_.trim" cir "" "f") (setq n 0) (repeat 180 (command (polar ptt (* (/ (* 2 n) 180.0) pi) (* r 1.01))) (setq n (1+ n)) ) (command "" "") (command "_.scale" "cp") (setq n 0) (repeat 180 (command (polar ptt (/ (* 2 n pi) 180) r)) (setq n (1+ n)) ) (command "" "" ptt 2 "") (command "redarw") (princ) ;(command "" "" pt (setq ptt (getpoint pt)));ok ,finish the choose and copy ;now how to get copied objects. and trim the things outside the circle. ;here I just want to trim the copied objects. ) Quote
blueshake Posted November 5, 2010 Author Posted November 5, 2010 here are some explaination. 1.draw a circle and give the position you want to place the enlarged objects. 2.copy the objects surround by the circle and put them in the position you set in step 1 3.trim the things beyond the circle and enlarge them but still something I can not figure out.when I move the circle, it can not show the circle in real time.it is strange. Quote
blueshake Posted November 5, 2010 Author Posted November 5, 2010 also I notice that these codes I commented can not work (command "_.move" enlargeCircle "" pt (setq ptt (getpoint pt))) it can not draw a circle in real time as I expected. Quote
blueshake Posted January 4, 2011 Author Posted January 4, 2011 I have finished the detail view codes.it is used to do the job as the picture show.hope s.b. can improve this.tt.lsp Quote
alanjt Posted January 4, 2011 Posted January 4, 2011 Why not just create another viewport at a different scale? No need to create multiple objects. Quote
blueshake Posted January 4, 2011 Author Posted January 4, 2011 I just want the objects inside the blue circle be enlarged . @alanjt. in your above way. can this be done? can you show me sth. thanks. 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.