+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Full Member eric_monceaux's Avatar
    Computer Details
    eric_monceaux's Computer Details
    Operating System:
    Windows 7 Home Premium (64-Bit)
    Computer:
    Toshiba Qosmio X505-Q880
    Motherboard:
    TOSHIBA Qosmio X505
    CPU:
    1.60 gigahertz Intel Core i7 Q 720 64-bit
    RAM:
    6GB DDR3
    Graphics:
    NVIDIA GeForce 360M
    Primary Storage:
    64 SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    18.4" Laptop Monitor, 19" LCD Secondary
    Discipline
    Architectural
    eric_monceaux's Discipline Details
    Occupation
    3D Designer/Draftsman
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    91

    Question Arc Segmenting with Lines to Center

    Registered forum members do not see this ad.

    So I have been searching the forums for a LISP that can divide an arc while adding mortar joints.

    The cast stone company I work for manufactures window surrounds and when I draw them, they have to be seperated into equal lengths with a 1/4" mortar joint. Currently what I do is use the DIVIDE command, then a little MLINE macro I wrote drawing an MLINE from the arc node to the center point of said arc.

    Back in 2006 a CADTutor.net member (CAB) and again in 2009 (SteveK) helped me in converting a qbasic formula into a LISP that I use for horizontal and vertical pieces, and I was wanting to see if something like that could be created for arc pieces as well.

    I have attached an example of a window surround.
    Attached Files
    Last edited by eric_monceaux; 23rd May 2012 at 10:25 pm. Reason: Added LISP routine CAB and SteveK helped me with.
    "If at first you don't succeed, then skydiving is probably not for you" -Unknown

  2. #2
    Full Member eric_monceaux's Avatar
    Computer Details
    eric_monceaux's Computer Details
    Operating System:
    Windows 7 Home Premium (64-Bit)
    Computer:
    Toshiba Qosmio X505-Q880
    Motherboard:
    TOSHIBA Qosmio X505
    CPU:
    1.60 gigahertz Intel Core i7 Q 720 64-bit
    RAM:
    6GB DDR3
    Graphics:
    NVIDIA GeForce 360M
    Primary Storage:
    64 SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    18.4" Laptop Monitor, 19" LCD Secondary
    Discipline
    Architectural
    eric_monceaux's Discipline Details
    Occupation
    3D Designer/Draftsman
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    91

    Default

    Also for background, here are the two posts I was referring to for the original development of the LISP.

    http://www.cadtutor.net/forum/showth...781#post275781.

    http://www.cadtutor.net/forum/showth...8968#post38968
    "If at first you don't succeed, then skydiving is probably not for you" -Unknown

  3. #3
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    If you take the total arc length put a rule what is maximum stone length user ? then get a number of blocks you should be able to work out arc length = no of joints + block length. Once you have this worked out its pretty easy to convert arclength to chords and draw stone blocks.

    Say something like 4 blocks = block length 23" is this ok NO try 5 then draw blocks.

    Arclength=rad*theta so can work out lengths etc simple maths chords are simple formula also if not sure just google circular formulas.
    A man who never made mistakes never made anything

  4. #4
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,634

    Default

    No real need to do curve calculations. Let the vlax-curve-* functions do that for you. Here's a sample:
    Code:
    (vl-load-com)
    
    (setq *SegmentPath:Gap* 0.
          *SegmentPath:GapStart* t
          *SegmentPath:GapEnd* t
          *SegmentPath:MaxLength* 10.)
    
    (defun c:SegmentPath  (/ en space len pos dist)
      (setq space (apply (if (> (getvar 'cvport) 1)
                           'vla-get-ModelSpace
                           'vla-get-PaperSpace)
                         (list (vla-get-ActiveDocument (vlax-get-acad-object)))))
      (while (progn (princ (strcat "\nGap Size: "
                                   (rtos *SegmentPath:Gap*)
                                   "; Max Length: "
                                   (rtos *SegmentPath:MaxLength*)
                                   "; "
                                   (if *SegmentPath:GapStart*
                                     "Gap at start; "
                                     "")
                                   (if *SegmentPath:GapEnd*
                                     "Gap at end; "
                                     "")))
                    (initget "Gap Max Start End")
                    (setq en (entsel "\nPick Path [Gap/Max/Start/End]: ")))
        (cond ((eq en "Gap")
               (if (setq en (getdist (strcat "\nEnter gap size <" (rtos *SegmentPath:Gap*) ": ")))
                 (setq *SegmentPath:Gap* en)))
              ((eq en "Max")
               (if (setq en (getdist (strcat "\nEnter max length <" (rtos *SegmentPath:MaxLength*) ": ")))
                 (setq *SegmentPath:MaxLength* en)))
              ((eq en "Start") (setq *SegmentPath:GapStart* (not *SegmentPath:GapStart*)))
              ((eq en "End") (setq *SegmentPath:GapEnd* (not *SegmentPath:GapEnd*)))
              (t
               (setq en  (car en)
                     len (vlax-curve-getDistAtParam en (vlax-curve-getEndParam en))
                     pos 0.)
               (if *SegmentPath:GapStart*
                 (setq pos *SegmentPath:Gap*)
                 (setq len (+ len *SegmentPath:Gap*)))
               (if *SegmentPath:GapEnd*
                 (setq len (- len *SegmentPath:Gap*)))
               (setq dist (/ len (1+ (fix (/ len (+ *SegmentPath:Gap* *SegmentPath:MaxLength*))))))
               (while (< pos len)
                 (vla-AddLine
                   space
                   (vlax-3d-point (vlax-curve-getPointAtDist en pos))
                   (vlax-3d-point (vlax-curve-getPointAtDist en (+ pos (- dist *SegmentPath:Gap*)))))
                 (setq pos (+ pos dist))))))
      (princ))
    It works on anything, not just arcs, but even polylines / splines.

    One prob though, the length is the length along the curve. Not the straight line length. For that you'd need to temporarily create a circle with radius length, then find the intersection along the curve.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  5. #5
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,590

    Default

    Try this code just for arc segment:
    Code:
     
    ;;__________________________________________Amort.lsp________________________________________________;;
    (vl-load-com)
    ;; get bulge radius
    ;; math by Juergen Menzi
    (defun get-radii (p1 p2 bulge)
    (abs (/ (distance p1 p2) 2 (sin (/ (* 4 (atan (abs bulge))) 2))
    )
    )
    )
    ;;--------------------------------------;;
    (defun ang-tangent (curve pnt)
    (angle
    '(0 0 0)
    (trans
    (vlax-curve-getFirstDeriv
    curve
    (vlax-curve-getParamAtPoint curve (trans (vlax-curve-getClosestPointTo curve pnt) 1 0))
    )
    0 1 T 
    )
    )
    )
    ;;--------------------------------------;;
    (defun get-segments (en pnt / par)
    (setq par (vlax-curve-getParamAtPoint
    en
    (vlax-curve-getClosestPointTo en pnt))
    )
    (list (vlax-curve-getPointAtParam en (fix par))
    (vlax-curve-getPointAtParam en (1+ (fix par)))
    )
    )
    ;;----------------------- main part ----------------------------;;
    (defun C:Amort(/ *error* adoc ang clay curve da en gap i joint leg num p1 p1e p2 par pe1 pe2 pn ps1 ps2 rad segs sset step stleg th)
    (defun *error* (msg)
    (vla-endundomark (vla-get-activedocument
    (vlax-get-acad-object))
    )
    (cond ((or (not msg)
    (member msg '("console break" "Function cancelled" "quit / exit abort"))
    )
    )
    ((princ (strcat "\nError: " msg)))
    )
    (setvar "nomutt" 0)
    (if clay (setvar "clayer" clay))
    (princ)
    )
     
    (setq adoc (vla-get-activedocument
    (vlax-get-acad-object)))
    (vla-startundomark adoc )
    (setq clay (getvar "clayer"))
    (setvar "clayer" "Mortar");<-- must be exist
    (or *num* (setq *num* 4));<-- hard coded
    (setq gap 0.25);<-- hard coded
    (setvar "nomutt" 0)
    (princ "\nSelect Shortest Arc Segment")
    (setvar "nomutt" 1)
    (if (setq sset (ssget "_:S:E" '((0 . "*LINE"))))
     
    (progn
    (setvar "nomutt" 0)
    (setq en (ssname sset 0))
    (initget 6)
    (setq num (getint (strcat "\nEnter the number of segments <" (rtos *num* 2 0) ">: ")))
    (cond (num) ((setq num 4)))
    (setq curve (vlax-ename->vla-object en))
    (setvar "osmode" 512)
    (setq p1 (getpoint "\nPick point on shortest arc segment: "))
    (setvar "osmode" 128)
    (setq p2 (getpoint p1 "\nPick point on longest arc segment: "))
    (setq joint (distance p1 p2))
    (setq p1e (vlax-curve-getclosestpointto curve p1))
    (setq par (fix (vlax-curve-getParamAtPoint
    curve
    (vlax-curve-getclosestpointto curve p1e)))
    )
    ;; get segment points
    (setq segs (get-segments curve p1e))
    ;; get radius of an arc
    (setq rad (get-radii (car segs) (cadr segs) (vla-getbulge curve par)))
    ;; get angle between gap points
    (setq da (* (atan (/ (/ gap 2) (sqrt (- (expt rad 2.0) (expt (/ gap 2.0) 2.0)))))2.0))
    ;; swap gap value
    (setq th (* da rad))
    ;; get the start length of segment
    (setq stleg (vlax-curve-getdistatparam curve par))
    ;; get arc length
    (setq leg (- (vlax-curve-getdistatparam curve (1+ par))
    (vlax-curve-getdistatparam curve par))
    )
    (setq step (/ leg num))
    (setq i 1)
    (repeat (1- num)
    (setq pn (vlax-curve-getpointatdist curve (+ stleg (* i step)))
    pn (vlax-curve-getclosestpointto curve pn))
     
    (setq ang (ang-tangent curve pn))
     
    (setq ps1 (vlax-curve-getpointatdist curve (- (vlax-curve-getdistatpoint curve pn) (/ th 2)))
    ps2 (vlax-curve-getpointatdist curve (+ (vlax-curve-getdistatpoint curve pn) (/ th 2))))
     
    (setq pe1 (polar ps1 (- ang (/ pi 2)) joint)
    pe2 (polar ps2 (- ang (/ pi 2)) joint))
    (command "_.line" "_non" ps1 "_non" pe1 "")
    (command "_.line" "_non" ps2 "_non" pe2 "")
     
    (setq i (1+ i)))
     
    )
     
    )
    ( *error* nil)
    (princ)
    )
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  6. #6
    Full Member eric_monceaux's Avatar
    Computer Details
    eric_monceaux's Computer Details
    Operating System:
    Windows 7 Home Premium (64-Bit)
    Computer:
    Toshiba Qosmio X505-Q880
    Motherboard:
    TOSHIBA Qosmio X505
    CPU:
    1.60 gigahertz Intel Core i7 Q 720 64-bit
    RAM:
    6GB DDR3
    Graphics:
    NVIDIA GeForce 360M
    Primary Storage:
    64 SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    18.4" Laptop Monitor, 19" LCD Secondary
    Discipline
    Architectural
    eric_monceaux's Discipline Details
    Occupation
    3D Designer/Draftsman
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    91

    Smile

    Ok. Sorry for my extremely late reply. It has been busy!

    fixo: Thank you very much for your LISP. It is very close to what I need, but there was one thing I cannot figure out how to correct. After the LISP is completed, It clears out all OSNAPS except PER. Can you guide me on how to fix that?

    irneb: What I like about your routine is that you can set your gap and add a gap to the beginning and end of the division. Is there a way that you can change the Start and Stop gap to be half of what the user inputted Gap number? (i.e. 0.25/2). I like that yours is adjustable to a max dimension. That would come in handy for the Stone Segments.LSP I initially submitted.

    So, if I could actually understand both of these routines, I would merge them together and then it would be great.
    1. Mortar Joints drawn in.
    2. The ability to set a max ceiling distance and gap diistance.
    3. The option to include half the gap dimension at the start and end of the arch.

    Thanks so much for your help guys. If either of you can steer me in the right direction to combine these LISPS that would be great, and if not, they will still be helpful!
    "If at first you don't succeed, then skydiving is probably not for you" -Unknown

  7. #7
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    Re osnaps pretty simple the variable osmode holds current snap value so

    Code:
    At start of code do
    (setq oldsnap (getvar "osmode"))
     
    at end of code do
    (setvar "osmode" oldsnap)
    A man who never made mistakes never made anything

  8. #8
    Full Member eric_monceaux's Avatar
    Computer Details
    eric_monceaux's Computer Details
    Operating System:
    Windows 7 Home Premium (64-Bit)
    Computer:
    Toshiba Qosmio X505-Q880
    Motherboard:
    TOSHIBA Qosmio X505
    CPU:
    1.60 gigahertz Intel Core i7 Q 720 64-bit
    RAM:
    6GB DDR3
    Graphics:
    NVIDIA GeForce 360M
    Primary Storage:
    64 SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    18.4" Laptop Monitor, 19" LCD Secondary
    Discipline
    Architectural
    eric_monceaux's Discipline Details
    Occupation
    3D Designer/Draftsman
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    91

    Default

    Registered forum members do not see this ad.

    @BIGAL That worked. Thanks!

    Oddly enough, when I loaded the AMORT.LSP today into a new drawing, the program would initialize but after "Select Longest Arc Segment:" the program terminates with no error report... I was able to get it to work yesterday, in a different drawing. The only change I actually made to the LSP is the "Select (long/short) Arc Segment:" was verbally backwards. Also I added a SETVAR for turning osnaps back on. Am I missing something?

    Code:
    ;;__________________________________________Amort.lsp________________________________________________;;
    (vl-load-com)
    ;; get bulge radius
    ;; math by Juergen Menzi
    (defun get-radii (p1 p2 bulge)
    (abs (/ (distance p1 p2) 2 (sin (/ (* 4 (atan (abs bulge))) 2))
    )
    )
    )
    ;;--------------------------------------;;
    (defun ang-tangent (curve pnt)
    (angle
    '(0 0 0)
    (trans
    (vlax-curve-getFirstDeriv
    curve
    (vlax-curve-getParamAtPoint curve (trans (vlax-curve-getClosestPointTo curve pnt) 1 0))
    )
    0 1 T 
    )
    )
    )
    ;;--------------------------------------;;
    (defun get-segments (en pnt / par)
    (setq par (vlax-curve-getParamAtPoint
    en
    (vlax-curve-getClosestPointTo en pnt))
    )
    (list (vlax-curve-getPointAtParam en (fix par))
    (vlax-curve-getPointAtParam en (1+ (fix par)))
    )
    )
    ;;----------------------- main part ----------------------------;;
    (defun C:Amort(/ *error* adoc ang clay curve da en gap i joint leg num p1 p1e p2 par pe1 pe2 pn ps1 ps2 rad segs 
    
    sset step stleg th)
    (defun *error* (msg)
    (vla-endundomark (vla-get-activedocument
    (vlax-get-acad-object))
    )
    (cond ((or (not msg)
    (member msg '("console break" "Function cancelled" "quit / exit abort"))
    )
    )
    ((princ (strcat "\nError: " msg)))
    )
    (setvar "nomutt" 0)
    (if clay (setvar "clayer" clay))
    (princ)
    )
     
    (setq adoc (vla-get-activedocument
    (vlax-get-acad-object)))
    (vla-startundomark adoc )
    (setq clay (getvar "clayer"))
    (setvar "clayer" "Mortar");<-- must be exist
    (or *num* (setq *num* 4));<-- hard coded
    (setq gap 0.25);<-- hard coded
    (setvar "nomutt" 0)
    (princ "\nSelect Longest Arc Segment")
    (setvar "nomutt" 1)
    (if (setq sset (ssget "_:S:E" '((0 . "*LINE"))))
     
    (progn
    (setvar "nomutt" 0)
    (setq en (ssname sset 0))
    (initget 6)
    (setq num (getint (strcat "\nEnter the number of segments <" (rtos *num* 2 0) ">: ")))
    (cond (num) ((setq num 4)))
    (setq curve (vlax-ename->vla-object en))
    (setvar "osmode" 512)
    (setq p1 (getpoint "\nPick point on Longest arc segment: "))
    (setvar "osmode" 128)
    (setq p2 (getpoint p1 "\nPick point on Shortest arc segment: "))
    (setq joint (distance p1 p2))
    (setq p1e (vlax-curve-getclosestpointto curve p1))
    (setq par (fix (vlax-curve-getParamAtPoint
    curve
    (vlax-curve-getclosestpointto curve p1e)))
    )
    ;; get segment points
    (setq segs (get-segments curve p1e))
    ;; get radius of an arc
    (setq rad (get-radii (car segs) (cadr segs) (vla-getbulge curve par)))
    ;; get angle between gap points
    (setq da (* (atan (/ (/ gap 2) (sqrt (- (expt rad 2.0) (expt (/ gap 2.0) 2.0)))))2.0))
    ;; swap gap value
    (setq th (* da rad))
    ;; get the start length of segment
    (setq stleg (vlax-curve-getdistatparam curve par))
    ;; get arc length
    (setq leg (- (vlax-curve-getdistatparam curve (1+ par))
    (vlax-curve-getdistatparam curve par))
    )
    (setq step (/ leg num))
    (setq i 1)
    (repeat (1- num)
    (setq pn (vlax-curve-getpointatdist curve (+ stleg (* i step)))
    pn (vlax-curve-getclosestpointto curve pn))
     
    (setq ang (ang-tangent curve pn))
     
    (setq ps1 (vlax-curve-getpointatdist curve (- (vlax-curve-getdistatpoint curve pn) (/ th 2)))
    ps2 (vlax-curve-getpointatdist curve (+ (vlax-curve-getdistatpoint curve pn) (/ th 2))))
     
    (setq pe1 (polar ps1 (- ang (/ pi 2)) joint)
    pe2 (polar ps2 (- ang (/ pi 2)) joint))
    (command "_.line" "_non" ps1 "_non" pe1 "")
    (command "_.line" "_non" ps2 "_non" pe2 "")
     
    (setq i (1+ i)))
     
    )
     
    )
    ( *error* nil)
    (setvar "osmode" 4211)
    (princ)
    )
    "If at first you don't succeed, then skydiving is probably not for you" -Unknown

Similar Threads

  1. How can I make center lines intersect on lines and not on free spaces?
    By livius in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 13
    Last Post: 27th Oct 2011, 02:47 am
  2. center lines
    By abishop in forum Autodesk Inventor
    Replies: 11
    Last Post: 9th Aug 2011, 03:41 pm
  3. No Center Lines in .pdf
    By Walker140 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 5
    Last Post: 13th Jan 2011, 11:01 pm
  4. center line for two lines.
    By blueshake in forum AutoLISP, Visual LISP & DCL
    Replies: 40
    Last Post: 23rd Oct 2010, 02:44 pm
  5. Center Lines....
    By Primal Scientist in forum AutoCAD General
    Replies: 5
    Last Post: 12th Nov 2009, 04:59 pm

Bookmarks

Posting Permissions

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