help with writing a lisp routine of tangent-tangent angle

help with writing a lisp routine of tangent-tangent angle

Anonymous
Not applicable
1,300 Views
11 Replies
Message 2 of 12

help with writing a lisp routine of tangent-tangent angle

Anonymous
Not applicable

could someone write a lisp routine that inserts a circle with a diameter of .0938 into a drawing at all instances of tangent-tangent angle?

 

below is an example of what this would look like:

 

Capture2.PNGCapture.PNG

0 Likes
Accepted solutions (2)
1,301 Views
11 Replies
Replies (11)
Message 1 of 12

Anonymous
Not applicable

could someone write a lisp routine that inserts a circle with a diameter of .0938 into a drawing at all instances of tangent-tangent angle?

 

below is an example of what this would look like:

 

Capture2.PNGCapture.PNG

0 Likes
Message 3 of 12

rkmcswain
Mentor
Mentor
0 Likes
Message 4 of 12

Kent1Cooper
Consultant
Consultant

Are those Lines, or Polylines, or....?  Operational questions also arise:  Would the User select the ones they want this done on, or should a routine try to find all of them itself?  Are they differentiatable from other such objects, such as by being within a limited range of length or something?  Are the corners always perpendicular?  Etc., etc. -- any more detail you can provide would be helpful.

Kent Cooper, AIA
0 Likes
Message 5 of 12

Anonymous
Not applicable

yeah, sorry about that.  I received an error that the listing wouldn't post so I tried again.  Guess it did post afterall.. not sure how to delete the other posting...

0 Likes
Message 6 of 12

Anonymous
Not applicable

They are polylines. The user could select or the routine could search to find all instances (I have no preference at this point as I believe either scenario would work) They will not be differential from other objects. Ideally this would apply to all instances of angles within the range of 10-179 degrees. Hope that helps.

0 Likes
Message 7 of 12

Ranjit_Singh
Advisor
Advisor
Accepted solution

Something like the following may work. Minimal testing and no error trap.

;;Ranjit Singh
;;8/25/17
(defun c:somefunc  (/ adoc c rad ss1 var)
 (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
 (setq rad (getdist "\nSpecify radius of circle: ")
       ss1 (ssget '((0 . "lwpolyline")))
       var (mapcar 'getvar '(osmode cmdecho nomutt)))
 (and ss1
      (mapcar 'setvar '(osmode cmdecho nomutt) '(0 0 1))
      (mapcar '(lambda (y)
                (mapcar '(lambda (x)
                          (command-s "._circle"
                                     (setq c (mapcar '/ (mapcar '+ (car x) (cadr x)) '(2 2)))
                                     (vlax-curve-getclosestpointto y c))
                          (command-s "._scale" (entlast) "" (last x) (/ rad (cdr (assoc 40 (entget (entlast)))))))
                        (mapcar '(lambda (x) (mapcar '(lambda (x) (vlax-curve-getpointatdist y x)) (list (- x rad) (+ x rad) x)))
                                (mapcar '(lambda (x) (vlax-curve-getdistatpoint y x))
                                        (cdr (reverse (cddr (reverse (vl-remove-if-not 'listp (mapcar 'cdr (entget y)))))))))))
              (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1))))
      (mapcar 'setvar '(osmode cmdecho nomutt) var))
 (vla-endundomark adoc)
 (princ))

 

circle_at_int_poly.gif

 

Message 8 of 12

Ranjit_Singh
Advisor
Advisor
Accepted solution

One, of probably many possible methods, is posted here. Adding here for reference

;;Ranjit Singh
;;8/25/17
(defun c:somefunc  (/ adoc c rad ss1 var)
 (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
 (setq rad (getdist "\nSpecify radius of circle: ")
       ss1 (ssget '((0 . "lwpolyline")))
       var (mapcar 'getvar '(osmode cmdecho nomutt)))
 (and ss1
      (mapcar 'setvar '(osmode cmdecho nomutt) '(0 0 1))
      (mapcar '(lambda (y)
                (mapcar '(lambda (x)
                          (command-s "._circle"
                                     (setq c (mapcar '/ (mapcar '+ (car x) (cadr x)) '(2 2)))
                                     (vlax-curve-getclosestpointto y c))
                          (command-s "._scale" (entlast) "" (last x) (/ rad (cdr (assoc 40 (entget (entlast)))))))
                        (mapcar '(lambda (x) (mapcar '(lambda (x) (vlax-curve-getpointatdist y x)) (list (- x rad) (+ x rad) x)))
                                (mapcar '(lambda (x) (vlax-curve-getdistatpoint y x))
                                        (cdr (reverse (cddr (reverse (vl-remove-if-not 'listp (mapcar 'cdr (entget y)))))))))))
              (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1))))
      (mapcar 'setvar '(osmode cmdecho nomutt) var))
 (vla-endundomark adoc)
 (princ))

circle_at_int_poly.gif

 

Message 9 of 12

john.uhden
Mentor
Mentor

I haven't studied the code, but I am very impressed with the results!

How are the results of your painting project?

John F. Uhden

0 Likes
Message 10 of 12

marko_ribar
Advisor
Advisor

I'll be **** if those two codes posted aren't the same... Where is the catch if I am missing it?

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 11 of 12

braudpat
Mentor
Mentor
Hello Rendit

1) BEAUTIFUL Routine !

2) French humour: now you must have a serious handicap !
You are forbidden to use MAPCAR !!

Regards, Patrice
Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 12 of 12

john.uhden
Mentor
Mentor

A good friend of mine, now deceased, always spoke of his favorite french breakfast... "a roll in bed with honey."  🙂

John F. Uhden

0 Likes