Author Topic: Coordinates and from the list  (Read 2936 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 245
Coordinates and from the list
« on: December 21, 2016, 02:38:11 PM »
When I execute the command list is shown different coordinates of those returned by ENTGET? The following drawing is attached.

>>>LIST

LWPOLYLINE  Layer: "0"
                            Space: Model space
                   Color: 5 (blue)    Linetype: "Continuous"
                   Handle = 6a
            Closed
    Constant width     0.000
Extrusion direction relative to UCS:
                   X=   -0.018  Y=   -0.026  Z=    1.000
              area   19621.913
         perimeter   705.994
          at point  X=690759.572  Y=9175550.765  Z=  -11.021
          at point  X=690743.650  Y=9175482.575  Z=  -13.055
          at point  X=691033.380  Y=9175472.680  Z=   -8.174
          at point  X=691035.413  Y=9175542.626  Z=   -6.341

>>>ENTGET
(-1 . <Entity name: 7ff68a706ea0>)
(0 . "LWPOLYLINE")
(5 . "6A")
(6 . "Continuous")
(8 . "0")
(10 -4.64207e+006 7.9409e+006)
(10 -4.6423e+006 7.94075e+006)
(10 -4.64203e+006 7.94084e+006)
(10 -4.64228e+006 7.94068e+006)

OK.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Coordinates and from the list
« Reply #1 on: December 21, 2016, 03:19:57 PM »
The drawing has a UCS other than World as current. Lisp functions return absolute World coordinates. Use the trans function to convert between the 2.

FELIX

  • Bull Frog
  • Posts: 245
Re: Coordinates and from the list
« Reply #2 on: December 21, 2016, 09:13:15 PM »
JEFF_M, HAVE YOU OPENED THE DRAWING?
OK.

danallen

  • Guest
Re: Coordinates and from the list
« Reply #3 on: December 21, 2016, 10:01:45 PM »
Jeff is most likely right even without opening the drawing. Set your UCS to world and list the pline and see if coordinates are the same. (I didn't open either, this is pretty basic)

FELIX

  • Bull Frog
  • Posts: 245
Re: Coordinates and from the list
« Reply #4 on: December 21, 2016, 10:21:37 PM »
dan allen, You also did not open the drawing. He is already in the world. The polyline has extrusion. The DXF 210 is not (0 0 1). How to have by Lisp the same coordinates displayed by the AutoCAD LIST command with the TRANS function?
OK.

danallen

  • Guest
Re: Coordinates and from the list
« Reply #5 on: December 21, 2016, 11:00:37 PM »
I typically don't download drawings because I don't know what version they were posted in, I'm in bricscad 15. Plus if I have open drawings, opening a posted drawing of unknown origin has a reasonable chance of crashing my CAD.

This search turned up some options that might help you:
https://www.google.com/search?q=site%3Atheswamp.org+extrusion+vector

I'd start with this post by Gile https://www.theswamp.org/index.php?topic=34198.msg395081#msg395081
which looks like it might help you convert object coordinate system (OCS) via DXF 210 to WCS or UCS.

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Coordinates and from the list
« Reply #6 on: December 22, 2016, 08:02:32 AM »
Code: [Select]
(trans (cdr (assoc 10 <entity-data>)) (cdr (assoc 210 <entity-data>)) 1)

FELIX

  • Bull Frog
  • Posts: 245
Re: Coordinates and from the list
« Reply #7 on: December 22, 2016, 09:42:50 AM »
Lee Mac, we are almost there.
See Lisp, then the result and then the LIST command.
Attached the DXF.

Code: [Select]
(SETQ ENT (CAR (ENTSEL)))
(FOREACH PP (ENTGET ENT)
  (IF (= (CAR PP) 10)
      (PRINT (TRANS (CDR PP) ENT 1))
  )
)
(PRINC)

Select object:
(686369.0 9.16919e+006 247708.0)
(686353.0 9.16912e+006 247706.0)
(686643.0 9.16911e+006 247711.0)
(686645.0 9.16918e+006 247713.0)

Command LIST:
 at point  X=690759.572  Y=9175550.765  Z=  -11.021
 at point  X=690743.650  Y=9175482.575  Z=  -13.055
 at point  X=691033.380  Y=9175472.680  Z=   -8.174
 at point  X=691035.413  Y=9175542.626  Z=   -6.341
OK.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Coordinates and from the list
« Reply #8 on: December 22, 2016, 10:00:53 AM »
@Felix: The polyline has a non-zero elevation.
Code: [Select]
(setq ent (car (entsel)))
(setq elst (entget ent))
(setq elev (cdr (assoc 38 elst)))
(foreach sub elst
  (if (= (car sub) 10)
    (print (trans (append (cdr sub) (list elev)) ent 1))
  )
)

FELIX

  • Bull Frog
  • Posts: 245
Re: Coordinates and from the list
« Reply #9 on: December 22, 2016, 10:14:26 AM »
EXCELLENT VERY GOOD.!!!

Thanks to everyone who answered the topic in a timely manner.

This forum is the best of all and without comparison.
OK.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Coordinates and from the list
« Reply #10 on: December 22, 2016, 11:23:53 AM »
Quick and dirty different activex twist for fun:

Code: [Select]
(defun lwcoords ( lwpolyline_object )
    (   (lambda ( coords z normal / x y result )
            (while (car (mapcar 'set '(x y) coords))
                (setq
                    result (cons (trans (list x y z) normal 0) result)
                    coords (cddr coords)
                )
            )
            (reverse result)
        )
        (vlax-get lwpolyline_object 'Coordinates)
        (vlax-get lwpolyline_object 'Elevation)
        (vlax-get lwpolyline_object 'Normal)
    )   
)
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: Coordinates and from the list
« Reply #11 on: December 22, 2016, 11:56:09 AM »
So many cats, so little skinnin' time ...

Code: [Select]
(defun foo ( lwpolyline_object )
    (   (lambda ( coords z normal / result )
            (repeat (/ (length coords) 2)
                (setq
                    result (cons (trans (list (car coords) (cadr coords) z) normal 0) result)
                    coords (cddr coords)
                )
            )
            (reverse result)
        )
        (vlax-get lwpolyline_object 'Coordinates)
        (vlax-get lwpolyline_object 'Elevation)
        (vlax-get lwpolyline_object 'Normal)
    )   
)
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: Coordinates and from the list
« Reply #12 on: December 22, 2016, 12:12:34 PM »
A vanilla variant mught be:

Code: [Select]
(defun foo ( lwpolyline_ename / data normal lz )
    (mapcar
       '(lambda (xy) (trans (append xy lz) normal 0))       
        (setq
            data   (entget lwpolyline_ename)
            normal (cdr (assoc 210 data))
            lz     (list (cdr (assoc 38 data)))
            data   (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq 10 (car x))) data))
        )
    )
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

FELIX

  • Bull Frog
  • Posts: 245
Re: Coordinates and from the list
« Reply #13 on: December 22, 2016, 12:20:48 PM »
MP, Did not like.
OK.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Coordinates and from the list
« Reply #14 on: December 22, 2016, 12:24:20 PM »
Perhaps in time; cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst