Polar help (I think)

Discussion in 'AutoCAD' started by coachball8, Aug 5, 2004.

  1. coachball8

    coachball8 Guest

    (setq brk (getreal "\nEnter Break Distance:"))
    (while
    (setq Ln (entsel "\nSelect line to break:"))
    (setq pt1(getpoint "\nSelect Intersection:"))
    (setq brkpt1(+ pt1 brk))
    (setq brkpt2(- pt1 brk))
    (command "_break" Ln "f" brkpt1 brkpt2)

    You get the idea. I need to determine if Ln is in X or Y. How do I do this? TIA
     
    coachball8, Aug 5, 2004
    #1
  2. If Ln is always a Line (not a polyline segment or something), you can get
    the direction it goes from its endpoints, group codes 10 & 11:

    (setq LnList (entget (car Ln)))
    (setq LnDirection (getangle (cdr (assoc 10 LnList)) (cdr (assoc 11
    LnList))))

    Then use (polar) to determine points along that direction (both ways) from
    pt1, with no need to save them as brkpt's:

    (command "_break" Ln "f" (polar pt1 LnDirection brk) (polar pt1 (+
    LnDirection pi) brk))

    It doesn't matter whether Ln is "X or Y" (I assume you mean whether it's
    horizontal or vertical), and it can even be non-orthogonal.

    Kent Cooper, AIA


    this? TIA
     
    Kent Cooper, AIA, Aug 5, 2004
    #2
  3. coachball8

    coachball8 Guest

    Thanks Kent, I appreciate the reply.
    (setq brk (getreal "\nEnter Break Distance:"))
    (while
    (setq Ln (entsel "\nSelect line to break:"))
    (setq pt1 (getpoint "\nSelect Intersection:"))
    (setq LnList (entget (car Ln)))
    (setq LnDirection(getangle (cdr (assoc 10 LnList))(cdr assoc 11 LnList))))
    (command "_break" Ln "f" (polar pt1 LnDirection brk)(polar pt1(+ LnDirection pi)brk))))
    Is that the way it should be? It bombs out on (cdr assoc 11 LnList))))
    ; error: bad argument type: stringp: (15.9763 6.03129 0.0)
    Any idea why?
     
    coachball8, Aug 5, 2004
    #3
  4. Are you wanting to break it along the line?
    You'll need to get the end points of the line, calculate the angle of the line, then use the polar
    function using the angle of the line.
     
    Allen Johnson, Aug 5, 2004
    #4
  5. (cdr assoc 11 LnList)
    should read
    (cdr (assoc 11 LnList))
     
    Allen Johnson, Aug 5, 2004
    #5
  6. coachball8

    Joe Burke Guest

    Maybe like this. The break command can be a bit tricky. For instance, I think you
    can't pass an ename for the object to break. Rather pass a point to select the object
    in this case.

    Joe Burke

    (defun c:test ( / *error* osm brk ln ang pt brkpt1 brkpt2)

    (defun *error* (msg)
    (setvar "osmode" osm)
    (if msg (princ msg))
    (princ)
    ) ;end

    (and
    (setq osm (getvar "osmode"))
    (setq brk (getdist "\nEnter break distance: "))
    (setq ln (entsel "\nSelect line to break: "))
    (setq vobj (vlax-ename->vla-object (car ln)))
    (setq ang (vlax-get vobj 'Angle))
    (setvar "osmode" 32)
    (setq pt (getpoint "\nSelect intersection point: "))
    (setq brkpt1 (polar pt ang brk))
    (setq brkpt2 (polar pt (+ ang pi) brk))
    (setvar "osmode" 0)
    (not (command "_break" (cadr ln) "f" brkpt1 brkpt2))
    )
    (*error* nil)
    ) ;end
     
    Joe Burke, Aug 5, 2004
    #6
  7. coachball8

    coachball8 Guest

    Yes, I am. And thanks for the reply. The break size is the distance back from the selected intersection on either side.
     
    coachball8, Aug 5, 2004
    #7
  8. coachball8

    coachball8 Guest

    Actually, it does read (cdr(assoc 11 LnList)). I just posted it wrong.
     
    coachball8, Aug 5, 2004
    #8
  9. coachball8

    coachball8 Guest

    Joe.........that's perfect! Thank you so much! I was really struggling with this one.
     
    coachball8, Aug 5, 2004
    #9
  10. coachball8

    Joe Burke Guest

    You're welcome.

    The (and... thing will prevent most potential errors. But it may not be bulletproof.

    Joe Burke


    one.
     
    Joe Burke, Aug 5, 2004
    #10
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.