Jump to content

Recommended Posts

Posted

Good day all,

 

So I've been looking at getting coordinates from a Mpolygon and my usual method of (vlax-get vla_object  'Coordinates) is not working. I then did a bit more digging and to see what the vla dump returns and there is no coordinates properties. 

 

This is the vla dump (I used @Lee Mac DumpObjectV1-2.lsp to get the data - Thanks Lee) :

; Property values:
;   Angle = 0.0
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff69162d990>
;   Area (RO) = 419.264
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000024d67bc7548>
;   Double = 0
;   Elevation = 0.0
;   EntityTransparency = "ByLayer"
;   GradientAngle = 0.0
;   GradientCentered = -1
;   GradientColor1 = Exception occurred
;   GradientColor2 = Exception occurred
;   GradientName = ""
;   Handle (RO) = "337"
;   HasExtensionDictionary (RO) = -1
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0000024d2dd9e8c8>
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   ObjectID (RO) = 43
;   ObjectName (RO) = "AcDbMPolygon"
;   OwnerID (RO) = 44
;   PatternFillTrueColor = #<VLA-OBJECT IAcadAcCmColor 0000024d2dd9f220>
;   PatternName = "_SOLID"
;   PatternTypeAsString = "Predefined"
;   Perimeter (RO) = 82.8437
;   PlotStyleName = "Color_53"
;   Scale = 1.0
;   Spacing = 1.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 0000024d2dd9e800>
;   Visible = -1
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()

 

So this is the solution that I've come up with, what do you guys think? Will this be a reliable solution?

 

(defun c:2test (/ ent)
    (setq ent (entget (car (entsel))))
    (_mpolycoord ent)
)

(defun _mpolycoord (ent /)
    (vl-remove-if-not '(lambda (x) (eq (car x) '10)) (member '(210 0.0 0.0 1.0) ent))
)

 

Posted

When importing shp files with Map I've always converted them to polylines. Never actually worked with them outside of GIS.

 

  • Like 1
Posted

I'm doing quite the opposite at the moment I need to export these to other GIS formats and connect to and API to draw this data live on a website! I much prefer working with normal polylines!

Posted (edited)

It also looks like Mpolygon's act kind of like a block in a way that the cords gathered from _mpolycoord are relative to the mpolygon not the UCS.

 

I also dumped a mpolygon and found this.

....
(93 . 8) 
(10 3.0700752477369 0.241102250925906 0.0) 
(10 3.21999436359511 2.22349846711586 0.0) 
(10 2.8649983635969 2.73649046710489 0.0) 
(10 0.406000363595012 2.94049046710279 0.0) 
(10 0.336118351855475 0.710920098215865 0.0) 
(10 -2.97433618887044 0.948314370230946 0.0) 
(10 -3.21999436359511 -2.47737999489618 0.0) 
(10 2.8294666532438 -2.94049046710279 0.0) 
(76 . 1) 
(63 . 256) 
(11 1411.34299715093 -359.973837993358 0.0) 
(99 . 0) 
...

 

You have to add point 11 to all the other point 10's to get the real location.

 

(defun C:test (/ ent off cord cords coords)
  (setq ent (entget (car (entsel))))
  (setq cords (mapcar 'cdr (vl-remove-if-not '(lambda (x) (or (eq (car x) '10)(eq (car x) '11))) (member '(210 0.0 0.0 1.0) ent))))
  (setq off (car (reverse cords)))    ;set off to point 11
  (setq cords (vl-remove off cords))  ;remove point 11 from list
  (foreach cord cords
    (setq coords (cons (mapcar '+ cord off) coords))  ;get correct coords by adding the offset to each point.
  )
)

 

so instead of getting a point list of

((3.0700752477369 0.241102250925906 0.0) (3.21999436359511 2.22349846711586 0.0) ...)

 

You get the correct point list of

((1414.17246380417 -362.914328460461 0.0) (1408.12300278733 -362.451217988254 0.0) ...)

 

Edited by mhupp
  • Like 2
  • Thanks 1
Posted

I am such a bird brain! I didn't even think about UCS! Thank you

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...