2D length from 3D polyline?
In the properties and in the command 'length' I only get the 3D length from a polyline but I want the 2D length.
0
Comments
-
I assume you want to retrieve the length of a polyline (be it 2d on an arbitrary plane or 3d) projected into the current UCS xy plane - then I think
flattening (a copy of) the polyline is the way to go.
You could use a small script to automate this task:
[code](defun C:projected_area ()
(prompt "Select an entity to project into the UCS xy plane:")
(command "_COPY" (car (entsel)) "" "0,0" "0,0")
(command "_PLAN" "")
(command "_FLATTEN" (entlast) "")
(setvar "CMDECHO" 1)
(command "_AREA" "_E" (entlast) "")
(entdel (entlast))
)[/code]
Note:
- the script contains no error checking etc., just use as a starting point
- for simplicity, the script uses command calls instead of dedicated lisp functions
- the results of the measurement can also be retrieved from the variables "AREA" and "PERIMETER"0 -
Thanks for your input. I thought there is a simple solution.0
-
I think there cannot be a simple solution - there is just no such thing as a "2d length", just the length of the projection onto a plane, but which one?
- the view plane (as does the flatten command)?
- the currrent UCS xy/xz/yz plane?
- the WCS xy/xz/yz plane?0 -
The flatten command will help me. If I want to keep the 3D line I have to make a copy. Unfortunately I can not copy a layer with all its objects.0
-
Yes, the flatten command should probably have an option that keeps the source objects.
So, if you want to process a single curve, just copy/paste the code listed above into your command line, type pro and select the projected_area entry from the command completion window.
If you want to process all objects on a layer I would proceed as follows:
- isolate the layer ("_LAYISO")
- select all objects and use "_COPYBASE" with a base point of 0,0 to copy the entities to the clipboard
- align the view to the desired plane (e.g. using "_PLAN")
- use "_FLATTEN" on all the objects
- optionally transfer the result to another layer
- paste the original objects again to 0,00
This discussion has been closed.