gvlisnas Posted June 16, 2008 Posted June 16, 2008 Hello there, Can anyone help me? I'm working with automatic vectorization of contours and i'm in desperate need of a lisp that will do this: Lets say i have a lot of plines and lines and i need to join them in a single polyline. That is a lisp that will : 1)ask for the first pline/line 2)ask for the second pline/line 3)convert the lines to plines 4)draw a pline between their closest vertexes 5)join the 3 plines 6)ask for the first pline/line and so on..... i need this to be done consequential that is ask for the first line/pline (click), the second (click-done), the first (click), the second (click-done) so that i don't call the lisp everytime. Please see the attached image. Quote
VovKa Posted June 16, 2008 Posted June 16, 2008 (defun C:TEST (/ Fuzz) (setq Fuzz (getreal "\nEnter fuzz distance: ")) (while t (command "_.PEDIT" "_M" (entsel) (entsel) "" "_J" "_J" "_A" Fuzz "" ) ) ) Quote
gvlisnas Posted June 16, 2008 Author Posted June 16, 2008 Thanks you vovka. it does work using a fuzz distance but the problem is that after it selects a line it asks me the pedit question "Convert lines and arcs to polylines?" and then gives me the choices of the pedit command. Can this be done automatically? That is enter as a default the answer YES to convert it to polyline and then not giving the choices of the pedit command? Because i have to hit ESC and that throws me out of the lisp and i have to re-enter the lisp. Quote
ASMI Posted June 16, 2008 Posted June 16, 2008 it does work using a fuzz distance but the problem is that after it selects a line it asks me the pedit question "Convert lines and arcs to polylines?" Set PEDITACCEPT = 1 Quote
gvlisnas Posted June 16, 2008 Author Posted June 16, 2008 Perfect! Thank you both. Can this be done without a fuzz distance? A rhetorical question Quote
ASMI Posted June 16, 2008 Posted June 16, 2008 Can this be done without a fuzz distance? A rhetorical question Remove (setq Fuzz (getreal "\nEnter fuzz distance: ")) line and change Fuzz variable inside (command expression to a some value bigger your usual distances between lines. We can't to know dimensions of your drawing. Quote
ASMI Posted June 16, 2008 Posted June 16, 2008 Without Fuzz request: (defun c:jln(/ l1 l2 fz) (setvar "PEDITACCEPT" 1) (if (and (setq l1(entsel "\nSelect first line > ")) (setq l2(entsel "\nSelect second line > ")) (setq fz(distance(cadr l1)(cadr l2))) (vl-cmdf "_.pedit" "_m" (car l1)(car l2) "" "_j" "_j" "_a" fz "") ); end and (c:jln) ); end if (princ) ); end c:jln Quote
filan1a Posted June 16, 2008 Posted June 16, 2008 thank you i needed that code Without Fuzz request: (defun c:jln(/ l1 l2 fz) (setvar "PEDITACCEPT" 1) (if (and (setq l1(entsel "\nSelect first line > ")) (setq l2(entsel "\nSelect second line > ")) (setq fz(distance(cadr l1)(cadr l2))) (vl-cmdf "_.pedit" "_m" (car l1)(car l2) "" "_j" "_j" "_a" fz "") ); end and (c:jln) ); end if (princ) ); end c:jln Quote
gvlisnas Posted June 16, 2008 Author Posted June 16, 2008 PERFECT!! Thank you so much! Without Fuzz request: (defun c:jln(/ l1 l2 fz) (setvar "PEDITACCEPT" 1) (if (and (setq l1(entsel "\nSelect first line > ")) (setq l2(entsel "\nSelect second line > ")) (setq fz(distance(cadr l1)(cadr l2))) (vl-cmdf "_.pedit" "_m" (car l1)(car l2) "" "_j" "_j" "_a" fz "") ); end and (c:jln) ); end if (princ) ); end c:jln Quote
alanjt Posted June 16, 2008 Posted June 16, 2008 if you didn't want to change the peditaccept (which, i can't imagine why anyone wouldn't want to change it) you could always do something like this: (if (equal (getvar 'peditaccept) 1) (command "pedit" "m" lines "" "j" "" "") (command "pedit" "m" lines "" "y" "j" "" "") );if i took this from my routine that will join my line/plines/arcs real quick. Quote
tikawawa Posted January 10, 2009 Posted January 10, 2009 I have a similar issue... I am using a laser cnc machine and in order for the cut to be performed correctly the polylines have to be connected together and as long as possible. (defun c:jln(/ l1 l2 fz) (setvar "PEDITACCEPT" 1) (if (and (setq l1(entsel "\nSelect first line > ")) (setq l2(entsel "\nSelect second line > ")) (setq fz(distance(cadr l1)(cadr l2))) (vl-cmdf "_.pedit" "_m" (car l1)(car l2) "" "_j" "_j" "_a" fz "") ); end and (c:jln) ); end if (princ) ); end c:jln I have alot of lines on my drawing, and lines sometimes have some overlaps. This program currently draws line between the vertices. I would like to change the program slighty. Can you please help? 1) Insted of selecting 1st line then 2nd line, I would like to select a multiple lines in a window or multiple click. 2) Instead of drawing a line between the vertices, Prompt for the "maximum distance between vertices to join" If less, vertices will move and snap together, If greater it will not move vertices to snap them together. (If vertices are a little off join them) 3) Prompt for the "maximum distance between vertices to draw line" If less, the program will draw a line between vertices, If greater the program will not connect the vertices. (If vertices are too far off, draw a line and joint them) 4) If vertices are closer than a certain distance with lines already drawn between them previously join them and remove the extra vertices. I think there might be 2 programs here. Thanks, ASMI, you previous program is very helpful !! Quote
Lee Mac Posted January 10, 2009 Posted January 10, 2009 This may help you - I wrote it for another guy on here using a cnc machine. (defun c:pljoin (/ *error* varLst oldVars oLst plnum ss) ;; --- Error Trap --- (defun *error* (msg) (mapcar 'setvar varLst oldVars) (if (= msg "") (princ "\nFunction Complete.") (princ (strcat "\n" (strcase msg))) ) ;_ end if (princ) ) ; end of *error* (setq varLst (list "CMDECHO" "PEDITACCEPT") oldVars (mapcar 'getvar varLst) ) ; end setq ;; --- Error Trap --- (vl-load-com) (vlax-for l (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object) ) ;_ end vla-get-ActiveDocument ) ;_ end vla-get-Layers (setq oLst (cons (vla-get-Name l) oLst) ) ; end setq ) ; end vlax-for (setq oLst (reverse oLst)) (setvar "cmdecho" 0) (setvar "PEDITACCEPT" 0) (setq plnum 0) (foreach lay oLst (if (setq ss (ssget "X" (list (cons 0 "LINE") (cons 410 (getvar "ctab")) (cons 8 lay) ) ;_ end list ) ;_ end ssget ) ;_ end setq (progn (command "_pedit" "M" ss "" "Y" "J" "0.0" "") (setq plnum (+ (sslength ss) plnum)) ) ;_ end progn ) ;_ end if ) ;_ end foreach (*error* "") (alert (strcat (rtos plnum 2 0) " Polylines Created/Joined.")) (princ) ) ;_ end defun 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.