Hello,
I'm trying to make a more streamlined way to make cutlists of parts drawn in AutoCad.
I've tried the DataExtraction command but it only gives lengths of lines, and the area of polylines otherwise it would be perfect.
Could someone make a lisp that iterates through all open drawings (or even just all drawings in a directory would be fine) and gives the overall Length and width of all polyline segments in a layer?
I suppose alternatively a lisp that iterated through a directory and exploded all polylines would work too as it would allow me to use the dataextraction method but it seems less clean :). I will except either though.
Thanks a bunch for the help.
Hello
I don't know if is a possibilite, but i made a code in VBA to do that.
Check here:
Sub Extract_PLS_Coords()
Dim AcadObj As AcadObject, PL As AcadLWPolyline, Coords As Variant
Dim i As Integer, j As Integer: i = 1
FileNum = FreeFile(): Open "C:\test.txt" For Output As FileNum
For Each AcadObj In ThisDrawing.ModelSpace
If TypeOf AcadObj Is AcadLWPolyline Then
Set PL = AcadObj
Coords = PL.Coordinates
Print #FileNum, "PL " & i & " - ID:" & PL.Handle & " Lenght:" & Round(PL.length, 3)
For j = 0 To UBound(Coords)
Print #FileNum, Coords(j)
Next j
i = i + 1
End If
Next AcadObj
Close FileNum
End Sub
After using this code in drawing he generate a txt file with ID of PL, Lenght, and also all coordinates of segment, like this:
I hope this help u.
Thanks Henri, this seems to be doing some sort of area calculation though. I need something that could tell me the overall length, and the overall width of a closed polyline (forgot to add that). Also i'd greatly prefer it be able to run through a directory of dwgs or all the opened drawings AND export to csv.
can u show me wich of this properties u need?
Area? Lenght? Global Width?
Another question: U need the sum of all polyline lenght, or separatede value for each one of them?
Sure!
So sguare.dwg as an example for getting polyline info, i'd need something that could look at closed polyline shapes in a list or directory of dwgs, and give me the overall length and overall width of those shapes categorized by their layer and dwg filename.
so in the case of square.dwg i'd like it to output a csv file that says:
"square.dwg, 0 (Layer), 453.05 (length), 233.8 (width)"
"______,_____,_____,_____"
...
..
.
That's all i would need. DataExtraction gets very close to this but is unfortunately unable to give closed polyline segment lengths which is the main thing i need from it.
The numbers i listed for square.dwg can be gotten by dimensioning sides of the square but i'm not sure there's a property for them...
Can't find what you're looking for? Ask the community or share your knowledge.