Draw cut line length and angle

Discussion in 'AutoCAD' started by Big 'D', Aug 23, 2004.

  1. Big 'D'

    Big 'D' Guest

    OK, I realize some of my questions seem intermediate and probably redundant to the more seasoned programmers but, that would be because I am a beginner (I know, that is redundant also). I have had some great help from this group and it has proven to be a terrific learning tool. Thank you. I had assistance in getting this routine to do what I wanted. Now, the requirements have altered some. The routine draws a cut line. Because of the different angles we may draw a cut line, I need the two ends to be parallel and the same length (say, 1/2"). I also need the middle line to be perpendicular. This is causing some problems because I am prompted for more line segments in between the arrows (which is what I want). On a simple cut line, I get messed up because I am prompted for the last point instead of specifying the length. Below is what I have so far. Does someone have a clean idea? (this beginners code is getting rather cumbersome)

    (defun c:ss ()
    ;
    ;
    ; This command will generate a typical "Cross-section" line
    ; drawn as a phantom line, complete with arrow heads at
    ; at both ends.
    ;
    (setvar "cmdecho" 0)
    (setq clayer (getvar "CLAYER"));;Add this line to save the current layer
    (command "-layer" "s" "p4" "")

    (if (not asize) (setq asize 0.30)) ;initial default arrow size
    (if (not PThk) (setq PThk 0.000)) ; " " Pline width

    ;;(defun GETR (val msg / tm) ;;Remove this function if you don't want to
    change the size
    ;; (setq tm (getreal (strcat msg " <" (rtos val 2 4) ">: ")))
    ;; (cond ((= (type tm) 'REAL) (eval tm))
    ;; ((= tm nil) (eval val))
    ;; (t (princ "\007 *error* not a REAL") (eval val)) ) )

    (defun loop ()
    (cond ((setq p2 (getpoint p1 " To point: ")) (command p2)
    (setq p0 p1) (setq p1 p2) (loop))
    ( t (command "u" (polar p1 (angle p1 p0) asize)
    "w" (/ asize 3) 0.0 p1 ""))))

    (setq p1 (getpoint " From point: "))
    (command "pline" p1 "w" 0.0 0.0)
    (setq p2 (getpoint p1 " To point: "))
    (command "w" 0.0 (/ asize 3) (polar p1 (angle p1 p2) asize)
    "w" PThk PThk p2)
    (setq p1 p2)
    (loop)
    (command "change" "l" "" "p" "lt" "phantom" "")
    (setvar "clayer" clayer);;Add this line to reset the current layer
    (eval "Done")
    )
     
    Big 'D', Aug 23, 2004
    #1
  2. I could suggest some things, but I'm not getting a good picture of the look
    of the end result you want. If it's supposed to look something like this
    crude approximation
    ____\
    | /
    |
    |
    |____\
    /
    and if the "middle" line segment is always just one straight line, then I'd
    be inclined to make the end lines-with-arrowheads as blocks, with their
    insertion points at the ends of the middle line segment. I have a menu item
    to do Building Section markers that way, and it even puts in pieces of text
    you can edit for drawing and sheet numbers, rotated appropriately no matter
    what direction the section mark points. It asks for one of the "corners" in
    the diagram, and a pointing direction, puts in a pointer block & text, then
    rotates the Snap system and turns ortho on for the middle line segment, then
    puts in another pointer block & text at the other end. (It also has you
    break much of the middle line segment out, which is often appropriate for
    Building Sections, but may not be for your application.)

    I'll send you that, if you want it as a starting point. It uses a block
    that's a long thin rectangular solid, with no arrowhead, but you could
    easily substitute a different block definition, though as written now mine
    doesn't allow for varying the length of the arrow parts. I have some
    thoughts about how to do that, though, in a way that could build it as a
    polyline:

    p2___\ p1
    | /
    |
    |
    |___\
    p3 / p4

    [Error handling, save and set layer, turn Ortho off, neutralize Osnap if you
    want, save Snap origin and angle and maybe value, etc. Set a respectable
    snap value if you want it to be easy to point it orthogonally or at 45
    degrees without Ortho on.]
    Ask for (and save) p2 first, then p1 for the aiming direction, and save the
    pointer-angle and pointer-distance between them.
    Use Snap Rotate to set the snap origin point to p2 and rotation angle to the
    pointer-angle, and turn Ortho on.
    Ask for p3 with (getpoint p2 <prompt>).
    Subtract the arrowhead length from the pointer-distance, and save that
    shaft-length.
    Draw your polyline from p1, with the arrowhead stuff you already have, using
    (polar p2 pointer-angle shaft-length) to locate the second (wide) end of the
    first arrowhead.
    Take the second zero-width segment to p2, and on to p3, then again (polar p2
    pointer-angle shaft-length) to the wide end of the other arrowhead.
    Reverse the arrowhead width adjustments to make one ending at zero width at
    p4.
    [Set layer back, reset Snap origin and angle and maybe value, turn Osnap
    back on, reset Ortho if you want, etc., etc.]

    Kent Cooper, AIA


    redundant to the more seasoned programmers but, that would be because I am a
    beginner (I know, that is redundant also). I have had some great help from
    this group and it has proven to be a terrific learning tool. Thank you. I
    had assistance in getting this routine to do what I wanted. Now, the
    requirements have altered some. The routine draws a cut line. Because of the
    different angles we may draw a cut line, I need the two ends to be parallel
    and the same length (say, 1/2"). I also need the middle line to be
    perpendicular. This is causing some problems because I am prompted for more
    line segments in between the arrows (which is what I want). On a simple cut
    line, I get messed up because I am prompted for the last point instead of
    specifying the length. Below is what I have so far. Does someone have a
    clean idea? (this beginners code is getting rather cumbersome)
     
    Kent Cooper, AIA, Aug 23, 2004
    #2
  3. The previous message's approach should work fine for the upper two examples
    in your drawing.

    For the bottom one, look into (cmdactive) for a way to let you put more
    segments in (there have been some other threads recently that used it). It
    would probably be a lot easier to do it that way if you used blocks for the
    pointer ends, because you could insert a block at "p2" with the
    pointer-angle for a rotation, then draw a Pline from there through as many
    segments as you want, and when cmdactive finds you've ended the Pline, it
    can insert another block. With cmdactive and Pline pointer ends, you'd
    probably have to start a second pline for the second pointer end, so it
    wouldn't all be one entity (thought you could then join them easily enough,
    I suppose).

    On the linetype generation, I can't figure out why it's behaving that way,
    but it did for me, too. I tried drawing a new one alongside that one, but I
    didn't bother with arrowheads, and it did the linetype generation fine. So
    I Pedited the arrowheads off the ends of yours, and enabled linetype
    generation, and oddly enough it worked as you'd expect! No idea why having
    varying widths in a Pline should keep linetype generation from working
    right, but that's the only difference I can see.

    Kent Cooper, AIA


    times where I will have extra segments in my cut line (as often happens). I
    can certainly use the infomation you sent to complete the socalled "plain"
    cut. But the number of my final point may vary.
    different possibilities. Do you know why pedit Linetype gen would not allow
    the shorter segments to show the phantom linetype?
     
    Kent Cooper, AIA, Aug 23, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.