Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing 3dpoly in lisp - missing elevation

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
tg_wilk
895 Views, 3 Replies

Drawing 3dpoly in lisp - missing elevation

Hi,

 

I have a problem while drawing 3d polyline in lisp. Although I use list of 3-coordinate points it ends up on 0 elevation. I have found many posts on drawing 3d polylines from coordinates and tried every solution that used command line approach - I feel I'm not strong enough yet to create entities or use vlax (as I don't know what it is). So I think there is some problem with my list, although I can't find it. Here's the fragment of code that gives me trouble:

          (print 3dlist)
	  (command "_.3dpoly")
	  (foreach pt 3dlist (command pt)) 
	  (command "")

 First line is just for debuging and it gives such result:

((823.607 2770.89 1000.0) (1430.87 3226.09 1218.59) (2805.42 3172.78 1614.8) (3289.59 1926.11 2000.0))

Although there clearly is a third coordinate in the list, 3d polyline ends up on xy plane with elevation 0. Ortho mode is off.

 

It is a part of a bigger program to change 2d polyline to 3d polyline given start and end elevation. 

 

Cheers

TW

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: tg_wilk

Hi TW,

your code works as expected, it creates a 3Dpoly with elevation in each vertex with the point list you have provided. Try to inspect the resulting list in your code. I would suggest to entmake the 3dpoly, and you will not have to worry about OSMODE settings, layer existence...

i.e.

;; Michael Puckett
(defun entmake-3dpoly (ptlist)
  (entmake
    '((0 . "POLYLINE")
      (100 . "AcDbEntity")
      (100 . "AcDb3dPolyline")
      (8 . "MyLayer");; your layer
      (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 x ptlist
    (entmake
      (list
        '(0 . "VERTEX")
        '(100 . "AcDbEntity")
        '(100 . "AcDbVertex")
        '(100 . "AcDb3dPolylineVertex")
        (cons 10 x)
        '(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")
     )
  )
)
;; your point list
(setq 3dlist '((823.607 2770.89 1000.0) (1430.87 3226.09 1218.59) (2805.42 3172.78 1614.8) (3289.59 1926.11 2000.0)))
;; usage
(entmake-3dpoly 3dlist)

 

Hope that helps

Henrique

 

Hope that helps

Henrique

EESignature

Message 3 of 4
tg_wilk
in reply to: hmsilva

I turned off ortho but have forgotten about object snap and vertices snapped to 2d polyline underneath. :faceplalm: on me 🙂 Thanks for the tip.

 

As for working with entities - I probably will eventually come to that need. I'm just starting with lisp though and I have very fuzzy idea how autocad database stores entities and why 3d polyline has to be separated into sequence of entities and, above all, what are the meaning of the codes - apart from 10 which I used when reading 2d polyline vertices.

 

I'm using such chellenges as an opportunity to learn, so I'm not willing to copy your example without understanding it - I'll try to read more about that and come back to it.  Are you able to produce such sequences from the top of you head after some time working with it or do you use some cheat-sheets?

 

Thank you very much for your answer.

 

Cheers

TW

 

Message 4 of 4
hmsilva
in reply to: tg_wilk

You're welcome, TW.

 

After some time working with dxf codes, with simple entities it's easy to write just from memory, but in the help files => Developer Documentation => DXF Reference, you'll have plenty useful information...

 

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost