Author Topic: Polyline tools  (Read 8924 times)

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3770
Re: Polyline tools
« Reply #15 on: May 22, 2012, 10:19:13 AM »
Camtasia
"How we think determines what we do, and what we do determines what we get."

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline tools
« Reply #16 on: May 22, 2012, 10:45:37 AM »
Actually I used CamStudio & VirtualDub, but Camtasia is also a good proggie.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline tools
« Reply #17 on: May 23, 2012, 03:41:48 AM »
Good tips.
Another idea I have is to simplyfy draw a arc  tagential between 2 lines and one known arc point. Have anybody a idea to can do it via Autolisp.

I think so here:

1) calculate angle a1 from line1 = 142grad
    calculate angle a2  from lin2  = 146grad
    so I get angle a3 = 360grad - a1 - a2 = 72grad
    and circle angle a4 = 180 - a3 = 108grad

The problem now is how can I get radius or centerpoint from arc?
Code: [Select]

(defun sel (/
;;; l1
;;; l2
;;; p1
;;; p2
;;; p3
;;; p4
;;; p5
)
  (if (not c:cal)(arxload "geomcal"))
  (while
    (not
      (and
(setq l1 (car (entsel "\nSelect line 1! "))
      l2 (car (entsel "\nSelect line 2! "))
      p1 (cdr (assoc 10 (entget l1)))
      p2 (cdr (assoc 11 (entget l1)))
      p3 (getpoint "\nSelect arc point! ")
      p4 (cdr (assoc 10 (entget l2)))
      p5 (cdr (assoc 11 (entget l2)))
      )
)
      )
    )
  )
(defun c:calc (/
;;;        a1
;;;        a2
;;;        a3
;;;        a4
       )
  (sel)
  (setq a1 (cal "ang (p1,p2)")
a2 (cal "ang (p4,p5)")
a3 (- 360 a1 a2)
a4 (- 180 a3)
)
  )


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline tools
« Reply #18 on: May 23, 2012, 05:53:05 AM »
You sure you want a lisp for that?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Polyline tools
« Reply #19 on: May 23, 2012, 06:02:52 AM »
You may want to look to this lisp...

http://www.theswamp.org/index.php?topic=39567.msg449135#msg449135

Among other cases included also LLP witch is your case...

M.R.

Irneb, you're absolutely wright - easiest is circle => 3 point (osnap : tan, tan, node) and finished...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline tools
« Reply #20 on: May 23, 2012, 06:29:19 AM »
You īre right !

(defun c:test () (vl-cmdf "_circle" "_3p" "_tan" pause "_tan" pause pause))  is great but I donīt want a circle I need a arc between the lines. Marco I couldnīt find my case in your link.

I have to create many arc and trim lines. I look for a solution which automatically create circle and trim lines and circles. In the end I would join line-arc-line to a polyline.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline tools
« Reply #21 on: May 23, 2012, 06:37:38 AM »
test
« Last Edit: May 23, 2012, 06:43:16 AM by cadplayer »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline tools
« Reply #22 on: May 23, 2012, 07:08:25 AM »
You īre right !

(defun c:test () (vl-cmdf "_circle" "_3p" "_tan" pause "_tan" pause pause))  is great but I donīt want a circle I need a arc between the lines. Marco I couldnīt find my case in your link.
What about trimming entlast at the point opposite of the line. Or after creating the circle, use entlast and obtain the tangent points from that. Then erase the temporary circle and create an arc using 3 points:
Code: [Select]
(defun perp  (pt1 pt2 pt3 /)
  (inters pt1 pt2 pt3 (polar pt3 (+ (angle pt1 pt2) (/ pi 2.)) 1000.) nil))

(defun c:ArcTTP (/ l1 l2 pt l1a l1b l2a l2b ptC en ed)
  (if (and (setq l1 (entsel "\nPick first line: "))
           (setq l2 (entsel "\nPick second line: "))
           (setq pt (getpoint "\nPick point passing through circle: ")))
    (progn
      (command "._circle" "_3P" "_tan" (cadr l1) "_tan" (cadr l2) "_non" pt)
      (setq ed (entget (setq en (entlast))))
      (entdel en)
      (setq ptC (cdr (assoc 10 ed))
            l1a (vlax-curve-getClosestPointTo (car l1) (cadr l1))
            l1b (vlax-curve-getPointAtParam (car l1) (fix (vlax-curve-getParamAtPoint (car l1) l1a)))
            l2a (vlax-curve-getClosestPointTo (car l2) (cadr l2))
            l2b (vlax-curve-getPointAtParam (car l2) (fix (vlax-curve-getParamAtPoint (car l2) l2a))))
      (command "._ARC" "_Non" (perp l1a l1b ptC) "_Non" pt "_Non" (perp l2a l2b ptC))))
  (princ))
Or you could use ribarms code to generate the centre point & radius of the circle - that's all you really need (no need to create a temporary circle). Then obtain the angles (start & end) of the arc (perhaps using my perp function onto the lines). And from that you should be able to generate the arc's DXF codes for use in entmake.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline tools
« Reply #23 on: May 23, 2012, 07:56:33 AM »
Yes this were it what I want
I continue little. Sorry my Lisp knowledge is not so good. Maybe you understand faster as I whatīs wrong. I need both lines trimed on arc. But lines entmakes wrong
Code: [Select]
(defun perp  (pt1 pt2 pt3 /)
  (inters pt1 pt2 pt3 (polar pt3 (+ (angle pt1 pt2) (/ pi 2.)) 1000.) nil))

(defun c:ArcTTP (/
l1
l2
pt
l1a
l1b
l2a
l2b
ptC
en
ed
)
  (if (and (setq l1 (entsel "\nPick first line: "))
           (setq l2 (entsel "\nPick second line: "))
           (setq pt (getpoint "\nPick point passing through circle: ")))
    (progn
      (command "._circle" "_3P" "_tan" (cadr l1) "_tan" (cadr l2) "_non" pt)
      (setq ed (entget (setq en (entlast))))
      (entdel en)
      (setq ptC (cdr (assoc 10 ed))
            l1a (vlax-curve-getClosestPointTo (car l1) (cadr l1))
            l1b (vlax-curve-getPointAtParam (car l1) (fix (vlax-curve-getParamAtPoint (car l1) l1a)))
            l2a (vlax-curve-getClosestPointTo (car l2) (cadr l2))
            l2b (vlax-curve-getPointAtParam (car l2) (fix (vlax-curve-getParamAtPoint (car l2) l2a))))
      (command "._ARC" "_Non" (setq l1a (perp l1a l1b ptC)) "_Non" pt "_Non" (setq l2a (perp l2a l2b ptC)))
      (entdel (car l1))
      (entmake
(list
  (cons 0 "LINE")
  (cons 8 (getvar "clayer"))
  (cons 10 l1a)
          (cons 11 l1b)
  )
)
      (entdel (car l2))
      (entmake
(list
  (cons 0 "LINE")
  (cons 8 (getvar "clayer"))
  (cons 10 l2a)
          (cons 11 l2b)
  )
)
      )
    )
  (princ)
  )



irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Polyline tools
« Reply #24 on: May 23, 2012, 08:28:27 AM »
You're using the points I've obtained from the 2 lines. Note the l1a and l2a are at the positions where the lines were picked. To get the opposite ends you should do something similar as for the calculations of l1b and l2b (just add 1 to the parameter number).

Though for what you're after is even simpler. Instead of the arc command, use fillet instead - the radius is code 40 of the circle's DXF data.

Edit something like this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:FilletPoint  (/ l1 l2 pt ed)
  2.   (if (and (setq l1 (entsel "\nPick first line: "))
  3.            (setq l2 (entsel "\nPick second line: "))
  4.            (setq pt (getpoint "\nPick point passing through circle: ")))
  5.     (progn (command "._circle" "_3P" "_tan" (cadr l1) "_tan" (cadr l2) "_non" pt)
  6.            (setq ed (entget (entlast)))
  7.            (entdel (entlast))
  8.            (command "._fillet" "_radius" (cdr (assoc 40 ed)) "._fillet" l1 l2)))
  9.   (princ))
« Last Edit: May 23, 2012, 08:36:36 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Polyline tools
« Reply #25 on: May 23, 2012, 08:54:05 AM »
Thank you so much for quickly help :-)