Author Topic: Draw a 3dpoly with point in a list  (Read 6903 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
Draw a 3dpoly with point in a list
« on: September 23, 2005, 09:45:04 AM »


Hello everybody.
The challenge I face today is to draw a 3dpoly line with points coming out of a list. The length of the list can vary.

Any Ideas?

Thanks in Advance

Bernd

Peter Jamtgaard

  • Guest
Re: Draw a 3dpoly with point in a list
« Reply #1 on: September 23, 2005, 11:00:23 AM »
Code: [Select]
(defun Draw3dpoly (lstOfPoints / lstPoint)
  (command "3dpoly")
  (foreach lstPoint lstOfPoints
    (command lstPoint)
  )
  (command "")
 )

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Draw a 3dpoly with point in a list
« Reply #2 on: September 23, 2005, 11:10:02 AM »
Code: [Select]
(apply 'command
    (append
       '(".3dpoly")
        points
       '("")
    )
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Draw a 3dpoly with point in a list
« Reply #3 on: September 23, 2005, 11:17:38 AM »
Code: [Select]
(defun foo ( points )

    (entmake
       '(
           (0 . "POLYLINE")
           (100 . "AcDbEntity")
           (100 . "AcDb3dPolyline")
           (66 . 1)
           (10 0.0 0.0 0.0)
           (70 . 8)
           (40 . 0.0)
           (41 . 0.0)
           (210 0.0 0.0 1.0)
           (71 . 0)
           (72 . 0)
           (73 . 0)
           (74 . 0)
           (75 . 0)
        )
    )
   
    (foreach point points
        (entmake
            (append
               '(
                   (0 . "VERTEX")
                   (100 . "AcDbEntity")
                   (100 . "AcDbVertex")
                   (100 . "AcDb3dPolylineVertex")
                )
                (list (cons 10 point))
               '(
                   (40 . 0.0)
                   (41 . 0.0)
                   (42 . 0.0)
                   (70 . 32)
                   (50 . 0.0)
                   (71 . 0)
                   (72 . 0)
                   (73 . 0)
                   (74 . 0)
                )
            )   
        )   
    )
   
    (entmake
       '(
           (0 . "SEQEND")
           (100 . "AcDbEntity")
        )
    )
   
    (princ)
   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Draw a 3dpoly with point in a list
« Reply #4 on: September 23, 2005, 12:15:27 PM »
Code: [Select]
(defun foo2 ( points / *error* document space )

    ;;  a different way to handle bozo input

    (cond
        (
            (or
                (null (listp points))
                (< (length points) 2)
                (null
                    (vl-every
                       '(lambda (point)
                            (apply 'and
                                (mapcar
                                   'numberp
                                    point
                                )
                            )
                        )
                        points
                    )
                )
            )
            (defun *error* (x)
                (princ
                    (strcat
                        "Bozo alert: Must be a list "
                        "of at least 2 points.\n"
                    )   
                )
                (princ)
            )
            (exit)
        )
    )
   
    ;;  let's rock it out               

    (setq space
        (if
            (zerop
                (vla-get-activespace
                    (setq document
                        (vla-get-activedocument
                            (vlax-get-acad-object)
                        )
                    )   
                )
            )
            (vla-get-paperspace document)
            (vla-get-modelspace document)
        )   
    )
   
    (vlax-invoke-method
        space
       'Add3DPoly
        (vlax-safearray-fill
            (vlax-make-safearray
                vlax-vbdouble
                (cons 0
                    (1-
                        (length
                            (setq points
                                (apply 'append
                                    (mapcar
                                       '(lambda (point)
                                            (while (< (length point) 3)
                                                (setq point
                                                    (append point
                                                      '(0)
                                                    )
                                                )
                                            )
                                            point
                                        )
                                        points
                                    )               
                                )
                            )   
                        )   
                    )
                )
            )
            points
        )       
    )

    (princ)

)
« Last Edit: September 23, 2005, 02:58:42 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Amsterdammed

  • Guest
Re: Draw a 3dpoly with point in a list
« Reply #5 on: September 23, 2005, 07:19:22 PM »
Wou,
eh, thanks Micheal. I'm impressed.

Bernd

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Draw a 3dpoly with point in a list
« Reply #6 on: September 23, 2005, 07:31:26 PM »
Wou,
eh, thanks Micheal.

Bernd

My pleasure. I frequently get kinda chatty after a migraine (yesterday I was wiped out).
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Draw a 3dpoly with point in a list
« Reply #7 on: September 23, 2005, 07:44:50 PM »
Now, ... THIS is funny.

[added]
The comparisons of code I mean ..
.. perhaps I do need testing after all.

« Last Edit: September 23, 2005, 08:16:14 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Draw a 3dpoly with point in a list
« Reply #8 on: September 23, 2005, 08:08:28 PM »
Code: [Select]
(apply 'command
    (append
       '(".3dpoly")
        points
       '("")
    )
)

What the . . .   didn't know you could do that

Thanks for the lesson Michael.  :kewl:
TheSwamp.org  (serving the CAD community since 2003)

LE

  • Guest
Re: Draw a 3dpoly with point in a list
« Reply #9 on: September 23, 2005, 08:20:33 PM »
other....
Code: [Select]
  (command "_.pline")
  (mapcar 'command pts)
  (command "_c")

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Draw a 3dpoly with point in a list
« Reply #10 on: September 23, 2005, 08:21:35 PM »
Yes Mark, thats very pretty isn't it.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE

  • Guest
Re: Draw a 3dpoly with point in a list
« Reply #11 on: September 23, 2005, 08:24:36 PM »
Or...
Code: [Select]
$ (setq pts (list a b c d "_c"))
((-6.67905 14.9635 0.0) (-3.9975 13.5826 0.0) (-6.09851 12.3811 0.0) (-6.99697 13.403 0.0) "_c")
_$ (command "_.pline")
  (mapcar 'command pts)

LE

  • Guest
Re: Draw a 3dpoly with point in a list
« Reply #12 on: September 23, 2005, 08:26:53 PM »
or...

Code: [Select]
$ (setq pts (list "_.pline" a b c d "_c"))
("_.pline" (-6.67905 14.9635 0.0) (-3.9975 13.5826 0.0) (-6.09851 12.3811 0.0) (-6.99697 13.403 0.0) "_c")
(mapcar 'command pts)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Draw a 3dpoly with point in a list
« Reply #13 on: September 23, 2005, 08:28:53 PM »
And the hits just keep on coming. Very nice Luis.  :kewl:
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Draw a 3dpoly with point in a list
« Reply #14 on: September 23, 2005, 08:30:33 PM »
Yes Mark, thats very pretty isn't it.

Indeed it is.  You guys never cease to amaze me.
TheSwamp.org  (serving the CAD community since 2003)