TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cadplayer on May 21, 2012, 08:24:39 AM

Title: Polyline tools
Post by: cadplayer on May 21, 2012, 08:24:39 AM
Hi!

I find this thread to can extend polylines dynamically

http://autocadtips.wordpress.com/2011/10/19/lengthen-polyline-endpoint-vertex/

For me itīs pretty to much number of mouseclicks, so maybe it is here a function already to use ?!
Title: Re: Polyline tools
Post by: CAB on May 21, 2012, 09:09:30 AM
I'm a little confused.
If you select the pline, grips appear. Pick the grip, it turns red and you are in stretch mode.
What more do you need?
Title: Re: Polyline tools
Post by: cadplayer on May 21, 2012, 09:23:02 AM
Yes I think itīs little complicate. Normally you can use Autocad to extend a polyline:
1) marks grips run stretch mode
2) press B for Base point
3) marks grips 1times again
4) type in EXT and than you can dynamically change length

Iīm asking if itīs possible to can collect 4 steps in 1.
1) type command
2) select grips and than extend

You can take a look with command (command "lengthen" "dy") but it works only with lines. I look for same for polylines
Title: Re: Polyline tools
Post by: alanjt on May 21, 2012, 09:52:34 AM
http://www.theswamp.org/index.php?topic=38086.msg430970#msg430970
Title: Re: Polyline tools
Post by: trogg on May 21, 2012, 10:00:58 AM
Also CAB's LengthenDe.lsp
http://www.theswamp.org/index.php?topic=23674.msg286702#msg286702 (http://www.theswamp.org/index.php?topic=23674.msg286702#msg286702)
Title: Re: Polyline tools
Post by: cadplayer on May 21, 2012, 10:35:47 AM
Thanks very good. Exactly what I want have.
Title: Re: Polyline tools
Post by: irneb on May 21, 2012, 10:50:24 AM
You can take a look with command (command "lengthen" "dy") but it works only with lines. I look for same for polylines
Which version ACad are you using? My Vanilla 2012 works fine with the Lengthen command on polylines.
Title: Re: Polyline tools
Post by: alanjt on May 21, 2012, 10:52:51 AM
You can take a look with command (command "lengthen" "dy") but it works only with lines. I look for same for polylines
Which version ACad are you using? My Vanilla 2012 works fine with the Lengthen command on polylines.
Must have been introduced in 2012 - not in 2011.
Title: Re: Polyline tools
Post by: cadplayer on May 22, 2012, 02:10:41 AM
I use Autocad C3D 2012 but can somebody explain me what is Vanilla 2012. I didnīt find explanation in Internet.
Title: Re: Polyline tools
Post by: BlackBox on May 22, 2012, 02:27:33 AM
When someone uses "Vanilla" as a description in this context, they are describing the original "Plain," or "Basic" AutoCAD. This is common among many users of "Verticals" like Map, Civil 3D, etc. this is very common in English. Pun intended.
Title: Re: Polyline tools
Post by: irneb on May 22, 2012, 03:11:39 AM
Yep, I always see it as "Vanilla ... like in ice-cream". I.e. the plain without frills.
Title: Re: Polyline tools
Post by: alanjt on May 22, 2012, 07:23:12 AM
Yep, I always see it as "Vanilla ... like in ice-cream". I.e. the plain without frills.
Except that, with ice-cream, Vanilla is not plain, it's vanilla flavored.  :-P
Title: Re: Polyline tools
Post by: cadplayer on May 22, 2012, 08:13:22 AM
Think I right vanilla-cream is baseAutocad without any extensions as for example civil...? Why didnīt work lengthen also with polylines in civil?
Title: Re: Polyline tools
Post by: irneb on May 22, 2012, 08:37:36 AM
Sorry, just reread the OP and the link. You're referring to Lengthen's Dynamic adjust - i.e. select then click new distance point. The other options seem to work on PL's, not the dynamic one.
Title: Re: Polyline tools
Post by: cadplayer on May 22, 2012, 09:18:29 AM
Thanks. Amazing your animation it discribe fast what you want to say. I know itīs not a question in this thread but how have done it?
Title: Re: Polyline tools
Post by: BlackBox on May 22, 2012, 10:19:13 AM
Camtasia
Title: Re: Polyline tools
Post by: irneb on May 22, 2012, 10:45:37 AM
Actually I used CamStudio & VirtualDub, but Camtasia is also a good proggie.
Title: Re: Polyline tools
Post by: cadplayer 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)
)
  )

Title: Re: Polyline tools
Post by: irneb on May 23, 2012, 05:53:05 AM
You sure you want a lisp for that?
Title: Re: Polyline tools
Post by: ribarm 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...
Title: Re: Polyline tools
Post by: cadplayer 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.
Title: Re: Polyline tools
Post by: cadplayer on May 23, 2012, 06:37:38 AM
test
Title: Re: Polyline tools
Post by: irneb 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.
Title: Re: Polyline tools
Post by: cadplayer 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)
  )


Title: Re: Polyline tools
Post by: irneb 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))
Title: Re: Polyline tools
Post by: cadplayer on May 23, 2012, 08:54:05 AM
Thank you so much for quickly help :-)