Results 1 to 6 of 6

Thread: Break horizontal line at intersection

  1. #1
    Member
    Join Date
    2017-02
    Posts
    4
    Login to Give a bone
    0

    Default Break horizontal line at intersection

    I have a fairly simple toolbar macro that I created many years ago that I am trying to convert to a lisp routine so I don't have to click the button each time, but I just can't figure it out with my poor programming skills. Hopefully one of you smart people can help me.
    Here's the basic rundown:
    Starting with a vertical and horizontal line that cross. The command has me select the apparent intersection of the 2 lines, draws a circle with a radius based on the dimscale, starts the trim command and selects the circle, selects the horizontal line within the circle to break it, then erases the circle.

    Macro:
    ^C^C_circle;_appint;\$m=$(/,$(getvar,dimscale),32);_trim;_last;;_none;$(eval,"@"$(/,$(getvar,dimscale),48)"<0");;_erase;_previous;;

    If someone could help me replicate this in lisp I would be very appreciative.
    Thanks.

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Break horizontal line at intersection

    A lisp version

    Code:
    ; simple circle trim
    ; 1st pick is always trimmed
    ; by Alan H April 2017
    
    (defun ah:ctrim ( / obj1 obj2 intpt rad ang pt)
    (setq obj1 (vlax-ename->vla-object (car (entsel "\nPick line1"))))
    (setq obj2 (vlax-ename->vla-object (car (entsel "\nPick line2"))))
    (setq intpt (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))
    (setq rad 20.0) ; put rad factor here
    (setq ang (angle 
    (vlax-safearray->list (vlax-variant-value (vla-get-startpoint obj1)))
    (vlax-safearray->list (vlax-variant-value (vla-get-endpoint obj1)))
    ))
    (setq pt (polar intpt ang (/ rad 2.0)))
    (command "circle" intpt rad)
    (setq circobj (entlast))
    (command "trim" circobj "" "near" pt "")
    (command "erase" circobj "")
    ) ; defun
    (ah:ctrim)

  3. #3
    Member
    Join Date
    2017-02
    Posts
    4
    Login to Give a bone
    0

    Default Re: Break horizontal line at intersection

    Thank you. But I was hoping to make it work with a single click like my original macro. Is that possible?

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Break horizontal line at intersection

    It is possible the single click would be at the intersection point and you would just check which object is horizontal you would use ssget and a simple little window select to find the two objects then as before a circle and a trim. I wrote a simple routine for any angle.

    Code:
    ; simple circle trim
    ; Trim horizontal only
    ; by Alan H April 2017
    
    (defun ah:ctrimH ( / obj1 obj2 pt1 pt2 pt3 rad ang)
    (setq oldsnap (getvar 'osmode))
    (setq oldangdir (getvar 'angdir))
    (setq oldaunits (getvar 'aunits))
    (setvar 'osmode 32)
    (setvar 'angdir 0)
    (SETVAR 'AUNITS 3)
    (setq pt1 (getpoint "Pick intersection"))
    (setvar 'osmode 0)
    (setq pt2 (polar pt1 (/ pi 4.0) 5))
    (setq pt3 (polar pt1 3.7 5))
    (setq ss (ssget "F" (list pt2 pt3)))
    (setq obj1 (vlax-ename->vla-object (ssname ss 0)))
    (setq obj2 (vlax-ename->vla-object (ssname ss 1)))
    
    (setq rad 20.0) ; put rad factor here
    
    (setq ang (angle 
    (vlax-safearray->list (vlax-variant-value (vla-get-startpoint obj1)))
    (vlax-safearray->list (vlax-variant-value (vla-get-endpoint obj1)))
    ))
    (if (or (= ang 0.0)(= ang pi))
    (setq pt2 (polar pt1 ang (/ rad 2.0)))
    (progn
    (setq ang (angle 
    (vlax-safearray->list (vlax-variant-value (vla-get-startpoint obj2)))
    (vlax-safearray->list (vlax-variant-value (vla-get-endpoint obj2)))
    ))
    (setq pt2 (polar pt1 ang (/ rad 2.0)))
    )
    )
    (command "circle" pt1 rad)
    (setq circobj (entlast))
    (command "trim" circobj "" "near" pt2 "")
    (command "erase" circobj "")
    (setvar 'angdir oldangdir)
    (SETVAR 'AUNITS oldaunits)
    (setvar 'osmode oldsnap)
    ) ; defun
    (ah:ctrim)
    Last edited by BIG-AL; 2017-04-25 at 03:33 AM.

  5. #5
    Member
    Join Date
    2017-02
    Posts
    4
    Login to Give a bone
    0

    Default Re: Break horizontal line at intersection

    Thank you AL. That ended up being a lot more complicated than I thought it would.

  6. #6
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Break horizontal line at intersection

    The complication is in the order that the two lines are drawn when you do the ssget it finds them but has no idea which one is at zero angle. The entities are retrieved in database order not direction etc.

Similar Threads

  1. Annotation - Dynamic Break Line (dyn-break)
    By Kernal_CAD_Monkey in forum Dynamic Blocks - Technical
    Replies: 0
    Last Post: 2012-07-30, 11:28 AM
  2. Thin line only when line is horizontal or vertically
    By adeuley in forum Revit Architecture - General
    Replies: 2
    Last Post: 2011-07-14, 05:59 PM
  3. Annotation - Dynamic Break Line (dyn-break)
    By barry.40197 in forum Dynamic Blocks - Sharing
    Replies: 10
    Last Post: 2011-01-13, 03:41 AM
  4. intersection of line and polygon
    By MikeJarosz in forum VBA/COM Interop
    Replies: 14
    Last Post: 2009-05-15, 05:35 PM
  5. Replies: 5
    Last Post: 2007-02-12, 10:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •