Jump to content

Help for Sequence circles.


teknomatika

Recommended Posts

Greetings.

I've been doing some very simpes routines.

One of them is designed to draw a sequence of circles with a radius increment values ​​and the z coordinate.

Unfortunately, without my being able to understand (I am still basic), the routine works properly sometimes, not others, drawing circles but without changing the z coordinate.

After the routine had wanted an evolution in order to draw a sphere composed of circles, but here I know that the requirement is complicated because the radius of each circle will have an appropriate value.

I appreciate the help.

 

;;v1
(defun c:scir ()
(setq pnt1 (getpoint "\n Sets center point of 1s circle:"))
(setq rcir (getreal "\n Sets the radius of circle:"))
(setq rinc (getreal "\n Sets a radius increment:"))
(setq incz (getreal "\n Sets z coord increment:"))
(setq ncir (getint "\n Sets n of circles:"))
(repeat ncir
(command "circle" pnt1 rcir)
(setq xpnt1 (car pnt1))
(setq ypnt1 (cadr pnt1))
(setq zpnt1 (+(caddr pnt1)incz))
(setq pnt1 (list xpnt1 ypnt1 zpnt1))
(setq rcir (+ rcir rinc))
);repeat
(princ)
);defun
(prompt "\nType SCIR")

 

scir_img.jpg

Link to comment
Share on other sites

You may have the OSNAP mode activated when there is no Z incrementation - try to disable it when input the center point:

 

(command "[color=red]_[/color]circle" [color=red]"_non"[/color] pnt1 rcir)

 

Regards,

Mircea

Link to comment
Share on other sites

Some quick revisions to your code:

 

(defun c:scir ( [color=red]/ incz ncir pnt1 rcir rinc[/color] )
   [color=green];; Localise your variables![/color]

   [color=red](if [/color][color=green];; allow for null user input[/color]
       [color=red](and[/color] [color=green];; all of the following must be non-nil[/color]
           (setq pnt1 (getpoint "\nCenter of 1st circle: "))
           (setq rcir (get[color=red]dist[/color] "\nCircle radius: " [color=red]pnt1[/color]))
           (setq rinc (getreal "\nRadius increment: "))
           (setq incz (getreal "\nZ-Coord increment: "))
           (setq ncir (getint "\nNumber of circles: "))
       [color=red])[/color]
       (repeat ncir
           (command "[color=red]_.[/color]circle" [color=red]"_non"[/color] pnt1 rcir)
[color=green]            ;; "[color=red]_.[/color]" to allow for other language versions and redefined commmands
           ;; [color=red]"_non"[/color] to ignore all OSnap when supplying the point[/color]

[color=red]            (setq pnt1 (list (car pnt1) (cadr pnt1) (+ (caddr pnt1) incz))
                 rcir (+ rcir rinc)
           )[/color]
       )
   [color=red])[/color]
   (princ)
)
(prompt "\nType SCIR")

Though, you may also want to look into using entmake for this task to increase performance, since creating simple entities (such as Circles / Lines) is relatively easy, e.g.:

 

(defun c:scir ( / incz ncir pnt1 rcir rinc )
   (if
       (and
           (setq pnt1 (getpoint "\nCenter of 1st circle: "))
           (setq rcir (getdist "\nCircle radius: " pnt1))
           (setq rinc (getreal "\nRadius increment: "))
           (setq incz (getreal "\nZ-Coord increment: "))
           (setq ncir (getint "\nNumber of circles: "))
       )
       (repeat ncir
           [color=red](entmake (list '(0 . "CIRCLE") (cons 40 rcir) (cons 10 pnt1)))[/color]
           (setq pnt1 (list (car pnt1) (cadr pnt1) (+ (caddr pnt1) incz))
                 rcir (+ rcir rinc)
           )
       )
   )
   (princ)
)
(prompt "\nType SCIR")

(Of course, this simple example doesn't account for changes in UCS)

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