tmelancon Posted May 2, 2016 Posted May 2, 2016 Just looking for a basic lisp routine that I would call a continuation, not really sure what to call it, so its hard to find something that exist. Anyways, I want to draw a simple line with 2 points on a hidden layer and then insert a "spline" on the end prompting user for rotation angle. The "spline" is a block on our server. Would eventually like to add the ability to get isoplane and rotate that spline to match the isoplane. See snap shot: Quote
ReMark Posted May 2, 2016 Posted May 2, 2016 Looks like the symbol one would use to show a pipe break. Why bother with a lisp routine when a block would suffice? Quote
tmelancon Posted May 2, 2016 Author Posted May 2, 2016 I guess I just wanted to expedite the line, the block, the rotation, as well as the layer switching and stuff. At the moment we draw a line 0.5 units in whichever direction the line is to be continuing. Next we type "1" which is the line break symbol insert shortcut command. Then insert it at the end of the line and rotate accordingly. Finally we select all and put on hidden layer. It doesnt take but maybe 10 seconds in total but I was just having some downtime and was thinking of a routine that could do all that for me. Quote
ReMark Posted May 2, 2016 Posted May 2, 2016 Nothing wrong with your request. I was just curious. Quote
tmelancon Posted May 2, 2016 Author Posted May 2, 2016 (edited) I was thinking something really simple line this. Still not too familiar with getting and storing points, otherwise I would written it to only be 2 points, storing the second point, then inserting the break symbol at p2 upon completion of drawing the two point line. (DEFUN C:CON (/ *ERROR* OLDLAYR OLDORTH) (princ "\nDraw your continuation line... ") (defun *error* (msg) (if oldlayr (setvar "clayer" oldlayr)) (if oldorth (setvar "orthomode" oldorth)) (if msg (prompt msg)) (princ) ) (setq oldlayr (getvar "clayer")) (setq oldorth (getvar "orthomode")) (command "._-layer" "s" "HIDDEN" "") (setvar "orthomode" 1) (command "_.LINE") (while (> (getvar "CMDACTIVE") 0) (command pause)) (princ "\nPlace your spline... ") (setvar "orthomode" 0) (Command "-insert" "spline-H" pause "" "" pause) (setvar "orthomode" OLDORTH) (command "._-layer" "s" OLDLAYR "") (*error* nil) (PRINC)) Edited May 5, 2016 by SLW210 Added Code Tags! Quote
tmelancon Posted May 2, 2016 Author Posted May 2, 2016 Ok so tweaked it a bit here, if anyone who is still reading this wants to chime in and teach me, I am willing to learn. (DEFUN C:CON (/ *ERROR* OLDLAYR OLDORTH pt1 pt2) (defun *error* (msg) (if oldlayr (setvar "clayer" oldlayr)) (if oldorth (setvar "orthomode" oldorth)) (if msg (prompt msg)) (princ) ) (setq oldlayr (getvar "clayer")) (setq oldorth (getvar "orthomode")) (command "._-layer" "s" "HIDDEN" "") (setvar "orthomode" 1) (setq PT1 (getpoint "\nStart point: ")) (initget 32) (setq PT2 (getpoint pt1 "\nInsert Break Location: ")) (command "._LINE" pt1 pt2 "") (setvar "orthomode" 0) (Command "-insert" "spline-H" pt2 "" "" "") (setvar "orthomode" OLDORTH) (command "._-layer" "s" OLDLAYR "") (*error* nil) (PRINC)) What I would like to do now is actually write something in here that gets the current isoplane and actually rotates my spline so it is on the same plane as my crosshairs. This is so when we type our continuation line (which I will work on coding into this routine next) it will look neat and on the same plane. See image: Quote
tmelancon Posted May 3, 2016 Author Posted May 3, 2016 Small update, this is what I have so far. It seems to work perfectly for vertical continuations but as soon as i go either way in left or right isometric it doesnt properly rotate the break. I am trying to figure where and how to code that piece. Still in development if someone wants to chime in. (DEFUN C:CON (/ *ERROR* OLDLAYR OLDORTH PLANE PT1 PT2 ROTN) (setvar "cmdecho" 0) (defun *error* (msg) (if oldlayr (setvar "clayer" oldlayr)) (if oldorth (setvar "orthomode" oldorth)) (if msg (prompt msg)) (princ) ) (setq oldlayr (getvar "clayer")) (setq oldorth (getvar "orthomode")) (setq l_exist_con (tblsearch "layer" "HIDDEN")) (if (not l_exist_con) (command "._-layer" "N" "HIDDEN" "C" "8" "HIDDEN" "ltype" "hidden2" "hidden" "") ) (command "._-layer" "s" "HIDDEN" "") (setvar "orthomode" 1) (setq plane (getvar "snapisopair")) (setq PT1 (getpoint "\nStart point: ")) (initget 32) (setq PT2 (getpoint pt1 "\nInsert Break Location and Rotation: ")) (command "._LINE" pt1 pt2 "") (IF (= PLANE 0) (PROGN (SETQ ROTN (DTR 60.0)))) (IF (= PLANE 1) (PROGN (SETQ ROTN (DTR 60.0)))) (IF (= PLANE 2) (PROGN (SETQ ROTN (DTR 120.0)))) (setvar "orthomode" 0) (Command "-insert" "spline-H" pt2 "" "" (rtd rotn)) ;(C:ISOTEXT) ::<<---- For future text placement (setvar "orthomode" OLDORTH) (command "._-layer" "s" OLDLAYR "") (*error* nil) (PRINC)) Quote
tmelancon Posted May 4, 2016 Author Posted May 4, 2016 (edited) Just about finished... For those of you who are viewing this and are interested in the LISP. I still have a little debugging to do. *********************** HIDDEN LINE CONTINUATION ******************************* ***************** WRITTEN BY TYLER J MELANCON 05/04/2016 *********************** (DEFUN C:CX (/ *ERROR* OLDLAYR OLDORTH PLANE pt1 pt2 xp1 xp2 yp1 yp2 l_exist_con) (setvar "cmdecho" 0) (defun *error* (msg) (if oldlayr (setvar "clayer" oldlayr)) (if oldorth (setvar "orthomode" oldorth)) (if msg (prompt msg)) (princ) ) (setq oldlayr (getvar "clayer")) (setq oldorth (getvar "orthomode")) (setq l_exist_con (tblsearch "layer" "HIDDEN")) (if (not l_exist_con) (command "._-layer" "N" "HIDDEN" "C" "8" "HIDDEN" "ltype" "hidden2" "hidden" "") ) (command "._-layer" "s" "HIDDEN" "") (setvar "orthomode" 1) (DEFUN DRAWBRK () (command "._LINE" pt1 pt2 "") (Command "-insert" "spline-H" pt2 "" "" "") (setq BREAK (ssget "l")) (PRIN1)) (defun one () (DRAWBRK) (prin1)) (defun two () (DRAWBRK) (command "._rotate" BREAK "" pT2 "180.0") (prin1)) (defun three (/ px) (DRAWBRK) (setq px (make_pt pT2 (dtr 90.0) 0.1)) (command "._mirror" BREAK "" pT2 px "y") (command "._rotate" BREAK "" pT2 "180.0") (prin1)) (defun four (/ px) (DRAWBRK) (setq px (make_pt pT2 (dtr 90.0) 0.1)) (command "._mirror" sockgrp "" pT2 px "y") (prin1)) (defun five (/ px) (DRAWBRK) (setq px (make_pt pT2 (dtr 90.0) 0.1)) (command "._mirror" BREAK "" pT2 px "y") (command "._rotate" BREAK "" pT2 "60.0") (prin1)) (defun six () (DRAWBRK) (command "._rotate" BREAK "" pT2 "300.0") (prin1)) (defun seven () (DRAWBRK) (command "._rotate" BREAK "" pT2 "120.0") (prin1)) (defun eight (/ px) (DRAWBRK) (setq px (make_pt pT2 (dtr 90.0) 0.1)) (command "._mirror" BREAK "" pT2 px "y") (command "._rotate" BREAK "" pT2 "240.0") (prin1)) (defun nine (/ px) (DRAWBRK) (setq px (make_pt p1 (dtr 90.0) 0.1)) (command "._mirror" BREAK "" pT2 px "y") (command "._rotate" BREAK "" pT2 "120.0") (prin1)) (defun ten (/ px) (DRAWBRK) (setq px (make_pt pT2 (dtr 90.0) 0.1)) (command "._mirror" BREAK "" pT2 px "y") (command "._rotate" BREAK "" pT2 "300.0") (prin1)) (defun eleven () (DRAWBRK) (command "._rotate" BREAK "" pT2 "240.0") (prin1)) (defun twelve () (DRAWBRK) (command "._rotate" BREAK "" pT2 "60.0") (prin1)) (defun right () (if (and (< xp1 xp2) (< yp1 yp2)) (three)) (if (and (> xp1 xp2) (> yp1 yp2)) (four)) (if (and (= xp1 xp2) (> yp1 yp2)) (six)) (if (and (= xp1 xp2) (< yp1 yp2)) (seven)) (prin1)) (defun top () (if (and (< xp1 xp2) (> yp1 yp2)) (nine)) (if (and (> xp1 xp2) (< yp1 yp2)) (ten)) (if (and (> xp1 xp2) (> yp1 yp2)) (eleven)) (if (and (< xp1 xp2) (< yp1 yp2)) (twelve)) (prin1)) (defun left () (if (and (< xp1 xp2) (> yp1 yp2)) (one)) (if (and (> xp1 xp2) (< yp1 yp2)) (two)) (if (and (= xp1 xp2) (> yp1 yp2)) (five)) (if (and (= xp1 xp2) (< yp1 yp2)) (eight)) (prin1)) (defun setTEST() (if (= test 0) (left)) (if (= test 1) (top)) (if (= test 2) (right)) (prin1)) (setq PT1 (getpoint "\nStart point: ")) (initget 32) (setq PT2 (getpoint pt1 "\nInsert Break Location and Rotation: ")) (setq test (getvar "snapisopair"))(setq headtype 1) (setq xp1 (car pT1)) (setq xp2 (car pT2)) (setq yp1 (cadr pT1)) (setq yp2 (cadr pT2)) (setTEST) (setvar "orthomode" 0) ;(C:ISOTEXT) ::<<---- For future text placement (setvar "orthomode" OLDORTH) (command "._-layer" "s" OLDLAYR "") (*error* nil) (PRINC)) Block: SPLINE-H.dwg Edited May 4, 2016 by tmelancon Quote
BIGAL Posted May 5, 2016 Posted May 5, 2016 Just me (command "._-layer" "s" OLDLAYR "") (setvar 'clayer oldlayer) Quote
tmelancon Posted May 5, 2016 Author Posted May 5, 2016 Thanks Big Al. Great input. Do you prefer to use (setvar 'clayer oldlayer) with your lisp routines instead of (command "._-layer" "s" OLDLAYR "") ? Are there any benefits or is this just a personal preferences? 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.