Lisp Request

Discussion in 'AutoCAD' started by John Gaubatz, Dec 2, 2004.

  1. John Gaubatz

    John Gaubatz Guest

    Does anyone out there know of a lisp or vba program that will scan a drawing
    and wherever there are polylines that cross, a centermark would be placed in
    that location?

    Thanks,
    John
    Raven Industries, Inc.
     
    John Gaubatz, Dec 2, 2004
    #1
  2. I doubt you will find anything that does this, floating
    around. Have you considered hiring someone to make
    it for you? It sounds like it would pay for itself in short
    order, assuming it is something you need to do often.
     
    Tony Tanzillo, Dec 2, 2004
    #2
  3. Hi John and Joe,

    It's not floating, but Map has this sort of functionality. It may be
    necessary to explode the polylines first - I haven't tested with polylines,
    but it works with lines and arcs.


    --

    Regards,


    Laurie Comerford
    www.cadapps.com.au
     
    Laurie Comerford, Dec 3, 2004
    #3
  4. John Gaubatz

    Joe Burke Guest

    Seems OK, though lightly tested.

    Joe Burke

    (defun c:IntersectPlines ( / doc objlst obj ptlst pt reslst rad )
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (ssget (list (cons 0 "LWPOLYLINE")))
    (vlax-for x (vla-get-activeselectionset doc)
    (setq objlst (cons x objlst))
    )
    (repeat (1- (length objlst))
    (setq obj (car objlst))
    (foreach x (cdr objlst)
    (setq ptlst (vlax-invoke obj 'IntersectWith x acExtendNone))
    (if ptlst
    (repeat (/ (length ptlst) 3)
    (setq pt (list (car ptlst) (cadr ptlst) (caddr ptlst)))
    (setq reslst (cons pt reslst))
    (setq ptlst (cdddr ptlst))
    )
    )
    )
    (setq objlst (cdr objlst))
    )
    (setq rad (/ (getvar "viewsize") 125.0))
    (if reslst
    (foreach x reslst
    (entmake
    (list '(0 . "CIRCLE")
    (cons 10 x)
    (cons 40 rad)
    )
    )
    )
    (princ "\nNo intersecting plines found. ")
    )
    (princ)
    )
     
    Joe Burke, Dec 4, 2004
    #4
  5. John Gaubatz

    John Gaubatz Guest

    I have considered hiring someone to do the code, but this is only the first
    part of the equation. Ultimately I would like to import this modified
    drawing into Inventor to use as a sketch base. But at this point, I am not
    sure changing the crossing polyline to centermarks will get me anything when
    imported into inventor.
    John
     
    John Gaubatz, Dec 6, 2004
    #5
  6. John Gaubatz

    John Gaubatz Guest

    Thanks Joe,
    I tried to code and it works, but it places a circle at the crossing
    polylines. I understand that is the way the code is written. Still it is
    better than what I have. Thanks again,
    John
     
    John Gaubatz, Dec 6, 2004
    #6
  7. John Gaubatz

    John Gaubatz Guest

    Hi Laurie,
    Where would I get this Map at? I would be interested in seeing it.
    Thanks,
    John
     
    John Gaubatz, Dec 6, 2004
    #7
  8. Hi John,

    Any Autodesk reseller with rights to sell it in your geographic area..
    You would buy it as an upgrade from your AutoCAD.

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Dec 6, 2004
    #8
  9. John Gaubatz

    Joe Burke Guest

    You're welcome, John.

    It was only intended to demonstrate how to establish the intersection point list. I
    used a circle at each so you could see it works. With a little modification, it might
    place a block at each point.

    Error checking was incomplete. For instance, in some cases it might find
    intersections at a previous selection set. Here's a slightly modified version which
    avoids that sort of thing.

    Joe Burke

    (defun c:IntersectPlines ( / doc objlst obj ptlst pt reslst rad )
    (and
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (ssget (list (cons 0 "LWPOLYLINE")))
    (vlax-for x (vla-get-activeselectionset doc)
    (setq objlst (cons x objlst))
    )
    (repeat (1- (length objlst))
    (setq obj (car objlst))
    (foreach x (cdr objlst)
    (setq ptlst (vlax-invoke obj 'IntersectWith x acExtendNone))
    (repeat (/ (length ptlst) 3)
    (setq pt (list (car ptlst) (cadr ptlst) (caddr ptlst)))
    (setq reslst (cons pt reslst))
    (setq ptlst (cdddr ptlst))
    )
    )
    (setq objlst (cdr objlst))
    )
    (setq rad (/ (getvar "viewsize") 125.0))
    (foreach x reslst
    (entmake
    (list '(0 . "CIRCLE")
    (cons 10 x)
    (cons 40 rad)
    )
    )
    )
    )
    (if reslst
    (princ (strcat "\nNumber of interstections found: "
    (itoa (length reslst))))
    (princ "\nNo intersecting plines found. ")
    )
    (princ)
    ) ;end
     
    Joe Burke, Dec 7, 2004
    #9
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.