Coordinates of centers of circles or arcs in a script

Next
 From:  Larry Fahnoe (FAHNOE)
9875.1 
My first attempt to write a script for MoI & I’m looking for some advice. My goal is to extract model information to assist during manual machining operations. Traditional CAM doesn't really apply since neither I nor my machines speak g-code, so I’m thinking of creating something that might be considered a "manual tool path". To achieve this I would add circles representing a cutter at various positions in the model and then extract the coordinates of the centers of those circles. I would then use those coordinates as I position the spindle to make various cuts. While my DRO does have cutter offsets, I thought this would be a good puzzle to solve with a script.

I’m starting with the framework from the SavePointFile script as that would produce acceptable output, but maybe later on I can generate either leaders or annotations. I’ve been using David Morrill’s documentation from Max’s site, the V4 beta release notes and various scripts as examples, but I’m stumbling over how to get the coordinates of the center of a circle or arc. As I have not found a “center” property my current thought is that the new crv.conicFrame or crv.conicRadius properties may get me closer, but I have not figured out how to use these.

Assuming Curves is the selected circles and arcs…

code:
    for ( var i=0; i < Curves.length; i++ )
    {
        if ( Curves.item( i).isCircle || Curves.item( i).isArc)
        {
            // Get the center point
        }
    }


Any advice or help is gratefully appreciated.

--Larry

EDITED: 10 Jul 2020 by FAHNOE

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Cemortan_Tudor
9875.2 
u are evaluating curve as entire joined* curve
crv.getSubObjects() will split into segments on which o can do checks

var curves = moi.geometryDatabase.getSelectedObjects().getCurves();
for (var i = 0; i < curves.length; ++i) {
for (var j = 0; j <= curves.item(i).getSubObjects().length; ++j) {
if ( curves.item(i).getSubObjects().item(j).isCircle || curves.item(i).getSubObjects().item(j).isArc)
// do smt
}
}

http://moi3d.com/forum/messages.php?webtag=MOI&msg=8010.8&highlight=yes and example

EDITED: 10 Jul 2020 by CEMORTAN_TUDOR

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
9875.3 In reply to 9875.2 
Thank you for the clarification Cemortan_Tudor, I will look into the distinction of segments vs. a joined curve.

My main question is *how* do I get the coordinates of the center of either a circle or arc?

code:
    var curves = moi.geometryDatabase.getSelectedObjects().getCurves();
    for (var i = 0; i < curves.length; ++i) {
        for (var j = 0; j <= curves.item(i).getSubObjects().length; ++j) {
        if ( curves.item(i).getSubObjects().item(j).isCircle || curves.item(i).getSubObjects().item(j).isArc)
           // How do I get the center point?
        }
    }


--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Cemortan_Tudor
9875.4 In reply to 9875.3 
curves.item(i).getSubObjects().item(j).conicFrame.origin;
ex:
var pointfactory = moi.command.createFactory('point');
pointfactory.setInput(0, curves.item(i).getSubObjects().item(j).conicFrame.origin);
pointfactory.commit();
- Tudor -
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
9875.5 In reply to 9875.4 
Thank you Tudor! Your code examples helped me to solve the puzzle, much appreciated.

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Larry Fahnoe (FAHNOE)
9875.6 In reply to 9875.5 
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All