Author Topic: I'd like to make a point  (Read 3016 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
I'd like to make a point
« on: December 15, 2008, 08:56:41 PM »
In short, the function uses grvecs to draw a multi colored sphere at the specified point, using the radius and colors1 and 2 if supplied. The radius value, if provided, is treated like the pdsize variable. The colors are treated per the grvecs function. If passed nils for radius, color1 and color2 it resorts to defaults, which are 1/100 screen size, red and green respectively.

Why: I needed visual confirmation of points generated by a program I was writing, but I didn't want to create any temporary entities. So I quickly bashed this out (hasn't been optimized yet).

Quick examples:

      ;; default 1/100 screensize, default red, default green
      (grpoint (getpoint "Pick a point: ") nil nil nil)

      ;; default 1/100 screensize, yellow, blue
      (grpoint (getpoint "Pick a point: ") nil 2 5)

      ;; 1/200 screensize, yellow, yellow
      (grpoint (getpoint "Pick a point: ") -0.5 2 2)

Code: [Select]
(defun GrPoint ( point radius color1 color2 / i j k angles )

    (setq radius
        (if (numberp radius)
            (if (minusp radius)
                (* (/ (abs radius) 100.0) (getvar "viewsize"))
                radius
            )
            (* 0.01 (getvar "viewsize"))
        )
    )

    (setq
        color1 (if (eq 'int (type color1)) color1 1)
        color2 (if (eq 'int (type color2)) color2 3)
        j      0.05
        k      (/ j 2.0)
        i      (- j)
    )

    (repeat (fix (/ 1.0 j))
        (setq angles
            (cons
                (+ k (* 0.5 pi (setq i (+ i j))))
                angles
            )
        )
    )

    (mapcar
       '(lambda ( args / point color start_angle angles )
            (setq
                point       (car args)
                color       (cadr args)
                start_angle (caddr args)
                angles      (cadddr args)
            )
            (grvecs
                (apply 'append
                    (mapcar
                       '(lambda ( incr_angle )
                            (list
                                color
                                point
                                (polar
                                    point
                                    (+ start_angle incr_angle)
                                    radius
                                )
                            )


                        )
                        (cadddr args)
                    )
                )
            )
        )
        (list
            (list point color1 (* 0.0 pi) angles)
            (list point color2 (* 0.5 pi) angles)
            (list point color1 (* 1.0 pi) angles)
            (list point color2 (* 1.5 pi) angles)
        )
    )

    point ;; return the original point to the caller

)

Sorry, don't have time to document this better or clean up the local vars. Will do down the road when I've more time.

Later dudes.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: I'd like to make a point
« Reply #1 on: December 15, 2008, 09:13:08 PM »
Nice job!!! Did something similar a few years ago, but this is better.
I drink beer and I know things....

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2139
  • class keyThumper<T>:ILazy<T>
Re: I'd like to make a point
« Reply #2 on: December 15, 2008, 11:15:10 PM »

Nicely bashed together Michael.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: I'd like to make a point
« Reply #3 on: December 16, 2008, 01:11:34 AM »
Thanks guys, dirty but did the job.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7529
Re: I'd like to make a point
« Reply #4 on: December 16, 2008, 10:21:42 AM »
Thanks guys, dirty but did the job.

I'm hope someday to write "dirty" code like you  :-P

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: I'd like to make a point
« Reply #5 on: December 16, 2008, 10:36:57 AM »
{shrug} Thanks Ron, I've got nothing on you. :)








































Except maybe 50 lbs. :(
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Maverick®

  • Seagull
  • Posts: 14778
Re: I'd like to make a point
« Reply #6 on: December 17, 2008, 12:09:45 AM »

Except maybe 50 lbs. :(

Put your head on his shoulder?  :-D

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: I'd like to make a point
« Reply #7 on: December 17, 2008, 09:01:54 AM »

Except maybe 50 lbs.

Put your head on his shoulder?

would take a LOT of tequila to get me to that point

















yes, I know what you meant: I can still get thru the door :P
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst