MoI discussion forum
MoI discussion forum

Full Version: Getting all points of a curve using a script

Show messages:  1-17  18-37  38-42

From: MajorGrubert (CARLOSFERREIRAPINTO)
18 Nov 2013   [#38]
Hi BurrMan,

Make some attempts with your sugestions but couldn't get it to work. Will keep trying.

Anyway, thanks for your help.

Carlos
From: BurrMan
18 Nov 2013   [#39] In reply to [#38]
Hey Carlos,
Not sure whats happening for you. It could be the point structure is not good for a "full through points" import?

Here's a video of a workflow:



Notice I have to break out anywhere where the points are the "straight lines". The through points tool wont know how to do that.

So anyway, maybe this helps. You can always revisit with questions of you need.
From: MajorGrubert (CARLOSFERREIRAPINTO)
19 Nov 2013   [#40]
Hi BurrMan,

Its working now, before i was saving as .3dm file and not as a .txt (never heard about this scripts before you mention).

Thanks for help and taking the time to make the video. Fantastic.

This is an amazing community!

Cheers

Carlos
From: Martin (MARTIN3D)
19 Nov 2013   [#41] In reply to [#5]
Hi Michael,
quote:

I've added in something for the next beta so that the start and end of curve _segments_ can also be retrieved. Right now they can only be gotten for the full curve, not for individual segments. Once this is in place then you would be able to get the segments by doing var segs = crv.getSubObjects(); , then each segment will respond to getStartPt() and getEndPt() in the next beta.


I tested that with todays beta, two selected polylines and the code below. It works fine. Thanks a lot for adding this!

code:
script:
var curves = moi.geometryDatabase.getSelectedObjects().getCurves();
for ( var i = 0; i < curves.length; i++ ) {
	var segments = curves.item(i).getSubObjects();
	for ( var j = 0; j < segments.length; j++ ) {
		var segment = segments.item(j);
		moi.ui.alert( "Curve " + i + "\n" + 
		"Segment " + j + " start: " + segment.getStartPt().x + ", " + segment.getStartPt().y + "\n" +
		"Segment " + j + " end: " + segment.getEndPt().x + ", " + segment.getEndPt().y );
	}
}

From: Michael Gibson
19 Nov 2013   [#42] In reply to [#41]
You're welcome Martin, I'm glad that worked!

Also another new thing related to polyline handling in the new beta - for the Rebuild command there's a new "Endpoints" mode which builds a new smooth curve that goes through the endpoints of the current curve's segments rather than sampling points at percentages along the curve's length. This can be useful for building a smooth curve through imported polylines like you sometimes get with PDF or DXF imports. It's basically the same as doing a "Through points" curve snapping each point onto polyline segment endpoints, but doing it all in one go.

- Michael

Show messages:  1-17  18-37  38-42