MoI discussion forum
MoI discussion forum

Full Version: Scripting the Trim command

Show messages:  1-4  5-24  25-32

From: yakas
24 Jan 2018   [#25] In reply to [#11]
Great, thank you.
From: bemfarmer
24 Jan 2018   [#26]
Thank you Michael.


I see, by adding an alert to the BlendCap script, which starts with a Closed edge, that the number of edges is stated as 3.
Since TRIM resulted in two "half" edges, is this an overstatement by 1, or is there a 3rd edge? (Or something else?)
(The index count in the BlendCap for loop would seem to be 0, 1, and 2... ?)

var brep_edges = trim_res.getEdges();

//// Test Code added by Brian:
moi.ui.alert ( 'number of edges = ' + brep_edges.length )

(Result is 3)

>>>>>>>>

(When Trim is applied to an open edge my tests in _TrimCurve12, (work in progress), show an "overstatement" of the number of edges as 2. ???)
(I'm planning on deducting this 1 or 2 count, for doing number of segments comparison...)


- Brian
From: Michael Gibson
24 Jan 2018   [#27] In reply to [#26]
Hi Brian, well probably there are 3 edges being generated somehow, although maybe it's something like an edge is being repeated in the list.

Can you please post your modified BlendCap script with anything that's required to duplicate your test so I can try it over here and see what's going on?

- Michael
From: bemfarmer
24 Jan 2018   [#28] In reply to [#27]
Hi Michael,
Here is the Test BlendCap with simple alert message.

- Brian

(For standalone curves, I've got _TrimCurve12 script working with Join and second Trim, to "fixup" the Trim problem with 8X trimpoints on the strange open curve.
But merge with open edges and reTrim is being stubborn.)

Edit 1/25/18: Brian removed the test script to avoid confusion. A knowledgeable programmer can easily add an alert message of # of brep edges.
From: Michael Gibson
24 Jan 2018   [#29] In reply to [#28]
Hi Brian, is there also any companion .htm file for the script, and when you are running it and getting that message are you using a particular object as the input? If so please post that object as well so I have all the same pieces as you when I try to reproduce your result over here.

- Michael
From: bemfarmer
24 Jan 2018   [#30] In reply to [#29]
Hi Michael,

Attached is simple open elliptical cone, and open cylinder.
BlendcapTest of edge of open elliptical cone, with closed edge, yields reading of 3 edges.
BlendcapTest of open cylinder with closed edge, yields reading of 4 edges.
There is no .htm file for this particular testing.

- Brian

Maybe I'll go at it using the nametags assigned...

Attachments:
OpenEllipticalConeAndCylinder.3dm


From: Michael Gibson
24 Jan 2018   [#31] In reply to [#30]
Hi Brian, thanks for posting the file.

So when doing this:

code:
var trim_res = trim_factory.getCreatedObjects().item(0);


The 'trim_res' object is the full brep which for the cone will now have 3 edges - the original "seam edge" plus 2 edges from the closed edge that was trimmed. The cylinder started with 3 edges (2 closed edges at the ends and one seam edges), and when you trim one of those in half there will now be 4 edges.

Probably the thing that's got you tripped up is you were expecting to receive edges as the output, but when you trim an edge the output is a brep.

So yeah probably tagging the edge with a name before trimming it would be good so you could find the new edges when looking through all the brep's edges. The name should inherit into the trimmed pieces.

- Michael
From: bemfarmer
25 Jan 2018   [#32] In reply to [#31]
Thank you Michael, your response is logical, and makes sense :-)

(I just did a blend with a cylinder and a pentagon, and got 18 (brep) edges, with BlendCapTest, on the open circular edge)

- Brian

Show messages:  1-4  5-24  25-32