Jump to content

Recommended Posts

Posted

Hi!

 

I saw the code below but I need the arc to be polyline to I can set linewidth. Thank you.

 

(defun c:CW ( / a )
 (graphscr) 
 (setq usercw (getpoint "Continuous Wiring \nSpecify start point of arc: "))
 (while usercw
  (setq a (getpoint usercw "\nSpecify second point of arc: "))
  (if a
   (progn
    (command "arc" usercw a pause)
    (setq usercw (getvar "lastpoint"))
   );progn
   (setq usercw nil)
  );if
 (setq a nil)
 );while
);end CW

 

Posted

Why not just use the Arc option of the standard PLINE command?

Posted

Just a quickie example.

(defun c:foo (/ 1p 2p md lw gr)
  (and
    (setq 1p (getpoint "\nSpecify start point : "))
    (while (setq 2p (getpoint "\nNext point : " 1p))
      (and (setq lw (entmakex (list '(0 . "LWPOLYLINE")
                                    '(100 . "AcDbEntity")
                                    '(100 . "AcDbPolyline")
                                    '(90 . 2)
                                    '(70 . 0)
                                    (cons 10 1p)
                                    '(40 . 0.0)
                                    '(41 . 0.0)
                                    '(42 . 0.1)
                                    '(91 . 0)
                                    (cons 10 2p)
                                    '(40 . 0.0)
                                    '(41 . 0.0)
                                    '(42 . 0.414215)
                                    '(91 . 0)
                              )
                    )
           )
           (setq lw (vlax-ename->vla-object lw))
           (while (and lw (= (car (setq gr (grread t 15 0))) 5))
             (vla-setbulge lw 0 (- (angle 1p 2p) (angle 1p (cadr gr))))
           )
      )
      (setq 1p 2p)
    )
  )
  (princ)
) (vl-load-com)

 

Posted (edited)
8 hours ago, Tharwat said:

Just a quickie example.


(vla-setbulge lw 0 (- (angle 1p 2p) (angle 1p (cadr gr))))

 

 

Note that bulge /= angle, and therefore this will yield unexpected results as the cursor moves around the vertices.

 

Instead, you might consider calculating the bulge in the following way, exploiting the inscribed angle theorem:

(defun c:test ( / a1 ex gr p1 p2 zv )
    (setq zv (trans '(0 0 1) 1 0 t))
    (if (setq p1 (getpoint "\nSpecify first point: "))
        (progn
            (while (setq p2 (getpoint p1 "\nSpecify next point: "))
                (setq ex
                    (entget
                        (entmakex
                            (list
                               '(000 . "LWPOLYLINE")
                               '(100 . "AcDbEntity")
                               '(100 . "AcDbPolyline")
                               '(090 . 2)
                               '(070 . 0)
                                (cons 010 (trans p1 1 zv))
                                (cons 010 (trans p2 1 zv))
                                (cons 210 zv)
                            )
                        )
                    )
                )
                (while (= 5 (car (setq gr (grread t 13 0))))
                    (setq a1 (/ (- (angle (cadr gr) p2) (angle p1 (cadr gr))) 2))
                    (entmod (subst (cons 42 (/ (sin a1) (cos a1))) (assoc 42 ex) ex))
                )
                (setq p1 p2)
            )
        )
    )
    (princ)
)

 

Edited by Lee Mac
  • Like 2
Posted

Yeah nice & perfect example, and thanks for taking the time to elaborate the procedure.

 

Aside info is that the entmod & vla-setbulge aren't interacting with the grread function in AutoCAD MEP although when the routine ends, the objects / arcs come true after all.

Posted

An alternative method solution posted somewhere as this question has been asked before is to draw 1st arc make a pline as each new arc is added use pedit join entlast.

Posted
4 hours ago, BIGAL said:

An alternative method solution posted somewhere as this question has been asked before is to draw 1st arc make a pline as each new arc is added use pedit join entlast.

 

For me at least, I don't think the goal is to deliver solutions to members other than negotiating and learning and sharing smart ideas as best as possible from each other in such threads when professional members contribute in, so keeping threads academic and a good reference for visitors must be considered a smart conduct as well. :) 

 

  • Like 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...