Jump to content

how to write a program to get the lines like in the attachment


aswini

Recommended Posts

hi i'm very new to autolisp i'm leraning programming now-a-days,if we draw two circles with same center point and with different radius by using polararray how can we draw lines on the circle at different angles from 0 to 360degrees from the same center.If you help me it is very useful to me

Thanks

Edited by aswini
Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • aswini

    7

  • BIGAL

    4

  • BlackBox

    3

  • pBe

    3

Top Posters In This Topic

You should look to POLAR function; it will take the angle argument in radians. Example of drawn from origin a 5 units line at 35 degrees:

(command "_LINE" '(0 0) (polar '(0 0) (* (/ 35.0 180.0) pi) 5.0) "")

Link to comment
Share on other sites

thanks for your reply,i'm getting that but it is not i wanted ,actually what i wanted is to draw 12 lines on two circles with 30degrees each at a time by using a program,can you help me to do that

 

Thanks.

Link to comment
Share on other sites

thanks for your reply,i'm getting that but it is not i wanted ,actually what i wanted is to draw 12 lines on two circles with 30degrees each at a time by using a program,can you help me to do that

 

Then, since you 'get' what Mircea was kind enough to point out (to use the Polar LISP Function), simply repeat the process 12 times (to generate 12 lines), using your 30 degree increment each time in your own custom program. :thumbsup:

Link to comment
Share on other sites

If i draw a rectangle in the middle of two circles like in the attachment ,then how to repeat them around the circle with different angles.can anyone help me plz

Thanks

Drawing1.dwg

Link to comment
Share on other sites

Moderator This is basicly the same question as the other post.

 

Good time to learn lisp in particular LINE pt1 pt2 & Polar & Entsel

Link to comment
Share on other sites

Moderator is this post 3 of the same question ? http://www.cadtutor.net/forum/showthread.php?69607-how-to-write-a-program-to-get-the-lines-like-in-the-attachment

 

http://www.cadtutor.net/forum/showthread.php?69606-how-to-repeat-the-lines-by-using-autolisp

 

Re lengthy you have not scratched the surface in HOW MANY LINES OF CODE.

 

Also in your first post was the lines meant to go from the centre of the circle ?

Edited by BIGAL
Link to comment
Share on other sites

(command "array" "P" "0,0" "14" "360" "Y")

 

There is a start:

 

Type:

(command "array") 

 

This will go through the options

Edited by SLW210
Link to comment
Share on other sites

becoming lenghty program.

It will not if you will use REPEAT and increment the angle at each draw, instead of having one line of code for each item to be drawn.

Link to comment
Share on other sites

Ok had my gripe an example like Msasu

 

(setq ang 0.0)
(repeat 10
(command "line" 0,0 (polar 0,0 ang 5) "")
;(command "line" Pt1 (polar pt1 ang dist) "")
(setq ang (+ ang 1.256))
)

 

Your turn use entsel to find centre of circle pt1 then distance dist=circle1cenpt-circle2cenpt

Link to comment
Share on other sites

Use command Array as Grant said before .

 

But the two circles are not in the same center point , so the array of lines would exceed the limits of the outer circle .

Link to comment
Share on other sites

For the fun of it:

 

(defun c:FunArray ( / ss bp ang angl )
           (setq ss (ssget))
           (setvar 'osmode 5)
           (setq bp (getpoint "\nPick Base point:"))
           (while (setq ang (getint (strcat "\nEnter Angle"
               (if ang "/Enter for none: " ": "))))
        (setq angl (cons ang angl)))
           (foreach aval angl
                  (command "_array" ss "" "C" bp aval "2" "Y")
                 )
           (princ)
           )


Link to comment
Share on other sites

"ya i want the lines from the center of the circle" when you see "Pick Base point" make sure your snap is set to "center" and pick circle edge. If in doubt at this point hold down shift and right button on mouse.

Link to comment
Share on other sites

I would've thought the OP would want a copy of the two lines at a diffrent angles in one go, But reading the post again, maybe he meant a diffrent angle at one time.

The first code i posted do just that.

 

For this one, using a constant angle specified by the user:

(defun c:FunArray  (/ ss bp)
     (setq ss (ssget))
     (setvar 'osmode 5)
     (setq bp (getpoint "\nPick Base point:"))
     (setq ang  [b][color=blue](getangle[/color][/b]
[b][color=blue]                      (strcat "\nEnter Angle"[/color][/b]
[b][color=blue]                              (if ang[/color][/b]
[b][color=blue]                                    (strcat " <" (angtos ang) ">: ")[/color][/b]
[b][color=blue]                                    ": ")))[/color][/b])
     [color=blue][b](initcommandversion 1)[/b][/color]
     (command "_array" ss ""
           "C"  bp [b][color=blue](/ (* ang 180.0) pi)[/color][/b]
           [color=blue][b]"-360"[/b][/color]  "Y")
     (princ)
     )

 

Besides Polar & Recatangular optioin, the array command also have "C" which accepts angles as input, then ask you for either number of items or angle to fill.

 

HTH

Link to comment
Share on other sites

I would've thought the OP would want a copy of the two lines at a diffrent angles in one go, But reading the post again, maybe he meant a diffrent angle at one time.

The first code i posted do just that.

 

For this one, using a constant angle specified by the user:

(defun c:FunArray  (/ ss bp)
     (setq ss (ssget))
     (setvar 'osmode 5)
     (setq bp (getpoint "\nPick Base point:"))
     (setq ang  [b][color=blue](getangle[/color][/b]
[b][color=blue]                    (strcat "\nEnter Angle"[/color][/b]
[b][color=blue]                            (if ang[/color][/b]
[b][color=blue]                                  (strcat " <" (angtos ang) ">: ")[/color][/b]
[b][color=blue]                                  ": ")))[/color][/b])
     [color=blue][b](initcommandversion 1)[/b][/color]
     (command "_array" ss ""
           "C"  bp [b][color=blue](/ (* ang 180.0) pi)[/color][/b]
           [color=blue][b]"-360"[/b][/color]  "Y")
     (princ)
     )

 

Besides Polar & Recatangular optioin, the array command also have "C" which accepts angles as input, then ask you for either number of items or angle to fill.

 

HTH

 

 

 

 

It is working excellent thanq verymuch,i have onemore doubt if i want the input as only number of lines and not the angle,what i have to do??

Thanks

Edited by aswini
Link to comment
Share on other sites

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