Dahzee Posted May 13 Posted May 13 This might seem a bit random and I have looked to see if this has been asked before. I would like to create a line on a specific layer, sometimes horizontal and sometimes vertical (it will always be one or the other) that extends left/right or top/bottom to the nearest entities. The idea of this is I have a CNC cutting machine that I want to break up the waste material to a smaller size, so adding extra lines in, cuts the material so the pieces are small enough to throw away rather than having a rectangle of material (cardboard in this case) which I then have to tear up to throw away. I presume the routine would go something like this: Start the command and it asks you if you want a horizontal or vertical line (preferably remembering the last option). Once you have chosen V or H you are then asked for a point. This almost always isn't a SNAP point so doesn't need a particular SNAP setting. A point is chosen and a line is created that extends to the nearest entities in both directions which would be either lines, arcs, circles or polylines. I created a video that almost shows what I mean (I cheated and added a small line in first ) which I then extended in both directions at the same time. Hopefully, the explanation and video make enough sense for it to be understood. Horizontal and Vertical to Entities.mp4 Quote
pkenewell Posted May 13 Posted May 13 (edited) Try this - no need to Select H or V just pick the points in a H or V direction (or at any other angle you want): (defun c:ELINE (/ p1 p2) (while (and (setq p1 (getpoint "\nSelect 1st point of Line: ")) (setq p2 (getpoint p1 "\NSelect 2nd point to define angle: ")) ) (progn (command "._line" "_non" p1 "_non" p2 "") (Command "._extend" "" p1 p2 "") ) ) ) I like this - I think I am going to keep this for my library since it is so simple. P.S. Let me know if you would prefer to have a special layer set or created and I can easily add that. Edited May 13 by pkenewell Quote
Dahzee Posted May 13 Author Posted May 13 @pkenewell Thanks for this it works even easier than I imagined. What would I need to add to make the lines on a specific layer and then change back to the current layer? As the layer used for these types of lines is only ever used for this purpose, so once I have finished adding them I need to go back to my current layer. Sorry, I don't want to sound ungrateful as your routine does do what I asked Quote
pkenewell Posted May 13 Posted May 13 (edited) Here you go. Set the variables mlayer, mlt, and mcol to your preferences: (defun c:ELINE (/ *error* cla mcol mlayer mlt p1 p2) (defun *error* (msg) (princ msg) (if cla (setvar "clayer" cla)) (if cmo (setvar "cmdecho" cmo)) ) (setq mlayer "ELINE_LAYER" mlt "CONTINUOUS" mcol 9) (command "._undo" "_be") (Setq cla (getvar "clayer") cmo (getvar "cmdecho")) (setvar "cmdecho" 0) (if (not (tblsearch "LAYER" mlayer)) (command "._layer" "_m" mlayer "_L" mlt "" "_C" mcol "" "") (setvar "clayer" mlayer) ) (while (and (setq p1 (getpoint "\nSelect 1st point of Line: ")) (setq p2 (getpoint p1 "\NSelect 2nd point to define angle: ")) ) (progn (command "._line" "_non" p1 "_non" p2 "") (Command "._extend" "" p1 p2 "") ) ) (setvar "clayer" cla) (command "._undo" "_E") (setvar "cmdecho" cmo) (princ) ) Note - I also added some basic error handling and an UNDO group. EDIT: Updated again to turn off command echoing. Edited May 13 by pkenewell Quote
Dahzee Posted May 13 Author Posted May 13 Absolutely perfect! Thank you very much for your help. 1 Quote
BIGAL Posted May 14 Posted May 14 pkenewell nice idea very simple. Dahzee dont forget press F8 will force a H or V. F8 off / on etc. 1 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.