Author Topic: coordinate conversion  (Read 3383 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
coordinate conversion
« on: January 10, 2005, 02:00:01 PM »
ok all
I have this code...

(setq pointa (getpoint "first point:")
pointb (getpoint "second point:"))

(entmake '((0 . "POLYLINE")
          (62 . 5)
          (6 . "continuous")
          (66 . 1)
) )
(entmake '((0 . "VERTEX")
(10 pointa)
) )
(entmake '((0 . "VERTEX")
(10 pointb)
) )
(entmake '((0 . "SEQEND")))


Now i need to know how to convert pointa and pointb to coordinate.
to make this working....

any idea ?
Keep smile...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
coordinate conversion
« Reply #1 on: January 10, 2005, 02:32:53 PM »
you cannot convert a variable within a quote block ....

Try ...
Code: [Select]

(entmake
  (list
    '(0 . "VERTEX")
    (cons 10 pointa)
  )
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Andrea

  • Water Moccasin
  • Posts: 2372
coordinate conversion
« Reply #2 on: January 10, 2005, 02:36:20 PM »
nice try....but not working....

the result is ..

(10 229.495 235.284 0.0)

and i need to have this..

(10 . 229.495 235.284 0.0)

with the dot between 10 and 229....
Keep smile...

Crank

  • Water Moccasin
  • Posts: 1503
coordinate conversion
« Reply #3 on: January 10, 2005, 02:47:53 PM »
It should work.

Try this:
Code: [Select]

(defun c:test (/ pointa pointb entp entv entq)
   ; Points in WCS:
   (setq  pointa  (getpoint "\n First point: "))
   (setq  pointb  (trans (getpoint  pointa  "\n Second point: ") 1 0))
   (setq pointa (trans pointa 1 0))
   
   (setq entp (list (cons 0 "POLYLINE")))
   (setq entv (cons 0 "VERTEX"))
   (setq entq (list (cons 0 "SEQEND")))
   (entmake entp)
   
;  null vertex:
   (entmake (list entv (cons 10  pointa)))

;  add a vertex (make loop to add more):
   (entmake (list entv (cons 10  pointb)))

   (entmake entq)
   (princ)
)


Is this for 3D?
I only use LWPOLYLINE's.
Vault Professional 2023     +     AEC Collection

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
coordinate conversion
« Reply #4 on: January 10, 2005, 02:55:18 PM »
It is worthwhile to note that point lists in entities DO NOT have the period between the point and the assoc number
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
coordinate conversion
« Reply #5 on: January 10, 2005, 04:03:46 PM »
Andrea, this works:
Code: [Select]

(setq pointa (getpoint "first point:")
      pointb (getpoint "second point:"))

(entmake (list '(0 . "POLYLINE")
      '(62 . 5)
      '(6 . "continuous")
      '(66 . 1)
      )
)
(entmake (list '(0 . "VERTEX")
      (cons 10 pointa)
      )
)
(entmake (list '(0 . "VERTEX")
      (cons 10 pointb)
      )
)
(entmake '((0 . "SEQEND")))

Andrea

  • Water Moccasin
  • Posts: 2372
coordinate conversion
« Reply #6 on: January 10, 2005, 04:14:06 PM »
Quote from: Jeff_M
Andrea, this works:
Code: [Select]

(setq pointa (getpoint "first point:")
      pointb (getpoint "second point:"))

(entmake (list '(0 . "POLYLINE")
      '(62 . 5)
      '(6 . "continuous")
      '(66 . 1)
      )
)
(entmake (list '(0 . "VERTEX")
      (cons 10 pointa)
      )
)
(entmake (list '(0 . "VERTEX")
      (cons 10 pointb)
      )
)
(entmake '((0 . "SEQEND")))


Jeff...don'T know why....but i've already tried this...but give me error..

the code of Crank it work well...bizzarre... :roll:

But thanks anyway...i appreciate.
Keep smile...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
coordinate conversion
« Reply #7 on: January 10, 2005, 04:27:33 PM »
The code provided by Jeff does indeed work, I suspect you tried it in a different manner than his code shows. Remember that if you quote a list element and you do not have a space between the number and data, it will fail.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
coordinate conversion
« Reply #8 on: January 10, 2005, 06:19:16 PM »
Andrea,
Look closely at what I posted. It is nearly identical to what you originally posted.....I just adjusted the use of (list) and the ' quote marks, as Keith has suggested.

David Bethel

  • Swamp Rat
  • Posts: 656
coordinate conversion
« Reply #9 on: January 11, 2005, 08:10:17 AM »
Here is the complete ( R12 ) list for heavy plines ( your points included. )  -David

Code: [Select]

(entmake (list (cons 0 "POLYLINE")
               (cons 6 "BYLAYER")
               (cons 8 "0")
               (cons 10 (list 0.0 0.0 0.0))
               (cons 39 0.0)
               (cons 40 0.0)
               (cons 41 0.0)
               (cons 62 256)
               (cons 66 1)
               (cons 70 0)
               (cons 71 0)
               (cons 72 0)
               (cons 73 0)
               (cons 74 0)
               (cons 75 0)
               (cons 210 (list 0.0 0.0 1.0))))
(entmake (list (cons 0 "VERTEX")
               (cons 6 "BYLAYER")
               (cons 8 "0")
               (cons 10 (list pointa))
               (cons 39 0.0)
               (cons 40 0.0)
               (cons 41 0.0)
               (cons 42 0.0)
               (cons 50 0.0)
               (cons 70 0)
               (cons 71 0)
               (cons 72 0)
               (cons 73 0)
               (cons 74 0)
               (cons 62 256)))
(entmake (list (cons 0 "VERTEX")
               (cons 6 "BYLAYER")
               (cons 8 "0")
               (cons 10 (list pointb))
               (cons 39 0.0)
               (cons 40 0.0)
               (cons 41 0.0)
               (cons 42 0.0)
               (cons 50 0.0)
               (cons 70 0)
               (cons 71 0)
               (cons 72 0)
               (cons 73 0)
               (cons 74 0)
               (cons 62 256)))
(entmake (list (cons 0 "SEQEND")
               (cons 8 "0")))
R12 Dos - A2K