Jump to content

Recommended Posts

Posted

Simple example, uses the information I posted in post#2.

 

(defun c:lazy nil
 (entmakex
   (list
     (cons 0 "LWPOLYLINE")
     (cons 100 "AcDbEntity")
     (cons 100 "AcDbPolyline")
     (cons 90 2)
     (cons 70 0)
     (list 10 1 0)
     (cons 42 (/ (sin (/ pi 16.)) (cos (/ pi 16.))))
     (list 10 (/ (sqrt 2) 2.) (/ (sqrt 2) 2.))
   )
 )
)

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    12

  • Michaels

    11

  • The Buzzard

    9

  • alanjt

    1

Top Posters In This Topic

Posted Images

Posted (edited)
How did you get on Michaels?

 

Thanks Lee .

It's very kind of you to follow up with me to get my codes running well , and to be able to understand the procedures of functions.

 

I have changed the way of my routine structure , since that Polyline entmakex is difficult to understan and to deal with. :)

 

** edit ** codes removed because it's not useful at the moment .

 

Many thanks.

 

Michaels

Edited by Michaels
Posted
(defun c:elb ( / UCSZ pt di r c b )

 (setq UCSZ (trans '(0. 0. 1.) 1 0 t))
 
 (if (and (setq pt (getpoint "\nInsertion: "))
          (setq di (getdist  "\nElbow Diameter: "))
     )
   (progn (setq r (/ di 2.) c (polar pt pi (* 1.5 di)) b (/ (sin (/ pi 16.)) (cos (/ pi 16.))))
     (entmakex
       (list
         (cons 0 "LWPOLYLINE")
         (cons 100 "AcDbEntity")
         (cons 100 "AcDbPolyline")
         (cons 90 4)
         (cons 70 1)
         (cons 10 (trans (polar pt pi r) 1 UCSZ))
         (cons 10 (trans (polar pt 0  r) 1 UCSZ))
         (cons 42 b)
         (cons 10 (trans (polar c (/ pi 4.) (* 2. di)) 1 UCSZ))
         (cons 10 (trans (polar c (/ pi 4.)        di) 1 UCSZ))
         (cons 42 (- b))
         (cons 210 UCSZ)
       )
     )
   )
 )
 
 (princ)
)

Posted
(defun c:elb ( / UCSZ pt di r c b )

(setq UCSZ (trans '(0. 0. 1.) 1 0 t))

(if (and (setq pt (getpoint "\nInsertion: "))
(setq di (getdist "\nElbow Diameter: "))
)
(progn (setq r (/ di 2.) c (polar pt pi (* 1.5 di)) b (/ (sin (/ pi 16.)) (cos (/ pi 16.))))
(entmakex
(list
(cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 4)
(cons 70 1)
(cons 10 (trans (polar pt pi r) 1 UCSZ))
(cons 10 (trans (polar pt 0 r) 1 UCSZ))
(cons 42 b)
(cons 10 (trans (polar c (/ pi 4.) (* 2. di)) 1 UCSZ))
(cons 10 (trans (polar c (/ pi 4.) di) 1 UCSZ))
(cons 42 (- b))
(cons 210 UCSZ)
)
)
)
)

(princ)
)

 

Wow! That was easy!

Posted
(defun c:elb ( / UCSZ pt di r c b )
(setq UCSZ (trans '(0. 0. 1.) 1 0 t))
 (if (and (setq pt (getpoint "\nInsertion: "))
          (setq di (getdist  "\nElbow Diameter: "))
     )
   (progn (setq r (/ di 2.) c (polar pt pi (* 1.5 di)) b (/ (sin (/ pi 16.)) (cos (/ pi 16.))))
     (entmakex
       (list
         (cons 0 "LWPOLYLINE")
         (cons 100 "AcDbEntity")
         (cons 100 "AcDbPolyline")
         (cons 90 4)
         (cons 70 1)
         (cons 10 (trans (polar pt pi r) 1 UCSZ))
         (cons 10 (trans (polar pt 0  r) 1 UCSZ))
         (cons 42 b)
         (cons 10 (trans (polar c (/ pi 4.) (* 2. di)) 1 UCSZ))
         (cons 10 (trans (polar c (/ pi 4.)        di) 1 UCSZ))
         (cons 42 (- b))
         (cons 210 UCSZ)
       ))))
 (princ)
)

 

I hope that one day I could handle things like that in the near future .:)

 

Many thanks.

 

Michaels

Posted (edited)

You're very welcome Michaels :)

 

Disregarding the elements coded for UCS compatibility, (i.e. the appearance of the trans function), the calculation of the vertex positions is perhaps the only other slightly difficult part of the code.

 

I therefore hope this diagram clears things in your mind:

 

BulgeExample.png

 

The vertices in the diagram are numbered in the same order as they are specified in the program, and the same variable names are used in the dimensions.

 

If you have any further questions about the diagram or code, just ask and I'll be happy to help clarify some more.

 

Lee

Edited by Lee Mac
Posted

That's really great and wonderful. :)

 

Now the idea is very clear to me , and all the favour back to your generous hard work for me.

 

I did not image that I could understand these kinds of complicated series of actions one day , but all because of your great favour to me.

 

Thanks Gentleman Lee . you're amazing.

 

Appreciated.

 

Michaels

Posted
You're very welcome Michaels :)

 

Disregarding the elements coded for UCS compatibility, (i.e. the appearance of the trans function), the calculation of the vertex positions is perhaps the only other slightly difficult part of the code.

 

I therefore hope this diagram clears things in your mind:

 

[ATTACH]24841[/ATTACH]

 

The vertices in the diagram are numbered in the same order as they are specified in the program, and the same variable names are used in the dimensions.

 

If you have any further questions about the diagram or code, just ask and I'll be happy to help clarify some more.

 

Lee

 

That is a very detailed explaination Lee, Great job.

Posted
That is a very detailed explaination Lee, Great job.

 

Thanks Buzzard :)

Posted
Thanks Buzzard :)

 

I remember about 3 years ago at another forum, I was writting command call programs and someone did not understand it. I did the same thing you did and it went off like a light in his head. I guess it true that a picture speaks a thousand words.

Posted
I guess it true that a picture speaks a thousand words.

 

Definitely - and it's independent of language barriers :)

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...