Jump to content

Recommended Posts

Posted

Hello!

 

I'm trying to write a lisp that takes all entities in a drawing and transform all coordinates of the entities to the new coordinate system using a rest api provided by our national mapping agency.

I got it working after some help from an earlier post, as well as some trial and error.

The problem now is that it works perfectly on drawings with only a few entities, but when trying it on a bigger drawing it gets slow and stops after a few seconds, having only transformed part of the drawing.

I don't know if the cause is sloppy programming on my behalf or limitations of using the api? Too much requests to the api? 

Any tips to implement this in a more efficient way?

I attached my lisp as well as a sample drawing with about 600 entities, at which point the problem already poses itself.

Rest API: https://cconvert.geo.be/coordinateTransformations/v1/swagger-ui/index.html#/

 

PS: This is my first little project in lisp, I'm a land surveyor with a geomatics background.

 

cconvert.lsp testdrawing.dwg

Posted

A few quick points:

  • You're creating a new instance of the WinHTTP object for every point you transform - this will be incredibly slow.
  • (if (member (car d) '(10 11 12 13 14 15 16 17 18)) is an incredibly dangerous assumption; these DXF groups have different meanings depending on the entity type which uses them - the only thing you can reliably derive from a DXF group is the data type of the value. For example, DXF group 11 for MTEXT & XLINEs is the direction vector (i.e. not a point), for an ELLIPSE it's a point relative to the center point (not an absolute point); changing groups 11, 12, 13 in this way for a WIPEOUT will completely corrupt it.
Posted

@Lee Mac Thanks for your remarks!

For the first point: would the recommended solution be to put all coordinates in a list, use the api to transform that list as a whole, and at last to rebuild the entities in the same order as they were added to the list?
For the second point: would the recommended solution then be to determine which values are coordinates depending on each entity type?

Thanks for your help!

Posted

Just a comment for this type of task I would use a cond looking at the entity type ie "Line" "Circle" etc and make a defun for each type so then can change the correct dxf codes.

 

Not sure but I think you can remove these from rest defun, and add them further down in code as suggested by Lee you only open the Winhttp once and send it data. Run (rest) at start. Maybe make this a new defun.

 

(vlax-invoke-method http_object 'send data)
  (setq json (vlax-get-property http_object "ResponseText"))
  (if http_object (vlax-release-object http_object))
  (setq json2 json)

 

(jsontolist (rest xi yi 0))

(jsontolist (doWinHTTP xi yi 0))

 

NOT TESTED.

 

Ps it may be worthwhile using VL as you can get properties by name rather than dxf code. eg Radius, coordinates. Then can see quickly what your changing.

Posted

IMHO, you’re using the wrong API

with Python you can use tools like AcDbGeoData, AcDbGeoCoordinateSystemTransformer, AcDbGeoPositionMarker

 

It’s not my area, but It’s my understanding the you build a coordinate system, I.e. UTM84-51, then use that transformation matrix to convert from Geo coordinates to drawing coordinates.

 

Like I mentioned, I don’t know how to do this myself, but here’s an example using  pyproj Transformer to setup AcDbGeoData in Python

https://www.theswamp.org/index.php?topic=59548.0

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...