SavePointFile

Next
 From:  probotix
11540.1 
Trying to run the SavePointFile script on V5. Has something changed in the API that would prevent it from running? It just quietly dies after done or cancel. It appears that ObjectPicker is not collecting anything.
  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:  Michael Gibson
11540.2 In reply to 11540.1 
Hi probotix, the very original one made for MoI v2 I think used ActiveX controls for file I/O which won't work on v4 or v5.

But there's an updated one here using the cross platform file streams, it should work on v5:
http://moi3d.com/forum/messages.php?webtag=MOI&msg=5124.2

- Michael
  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:  probotix
11540.3 In reply to 11540.2 
Yes, that's the one I am using.
  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:  probotix
11540.4 In reply to 11540.3 
Also, I can get _SavePointNetwork to work, (it uses ObjectPicker.allowStandaloneCurves), but the point data is not correct. Yet, _PointCoord works fine and gives displays the expected data, but its quite different because it uses createPointPicker instead of createObjectPicker.
  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:  probotix
11540.5 In reply to 11540.4 
Okay, maybe I dont understand how SavePointFile works. If I create just raw points, it works fine. But what I want to do is find the points of a polyline or curve and export those points.
  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:  Frenchy Pilou (PILOU)
11540.6 
Not exactly the same ... i have not the original ...only in French...
LabelPointsCoordinates by Michael Gibson
https://moiscript.weebly.com/points-xyz.html
---
Pilou
Is beautiful that please without concept!
My Moi French Site My Gallery My MagicaVoxel Gallery
  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:  probotix
11540.7 In reply to 11540.6 
Okay, I have the basic functionality of what I'm trying to accomplish:

function arcCAM()
{
var ObjectPicker = moi.ui.createObjectPicker();
ObjectPicker.allowCurves();
if ( !GetObjects( ObjectPicker, true ) )
return;

var curves = ObjectPicker.objects;

//alert(Object.keys(curves.item(0).getSubObjects()));

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);
var type = "Line";
var arcCenterX = 0;
var arcCenterY = 0;
var arcRadius = 0;
if ( curves.item(i).getSubObjects().item(j).isCircle || curves.item(i).getSubObjects().item(j).isArc )
{
type = "Arc"
arcCenterX = round(curves.item(i).getSubObjects().item(j).conicFrame.origin.X, 3);
arcCenterY = round(curves.item(i).getSubObjects().item(j).conicFrame.origin.Y, 3);
arcRadius = round(curves.item(i).getSubObjects().item(j).conicRadius, 3);
}

alert( "Curve " + i + "\n" +
type + " " + j + " start: " + segment.getStartPt().x + ", " + segment.getStartPt().y + "\n" +
type + " " + j + " end: " + segment.getEndPt().x + ", " + segment.getEndPt().y + "\n" +
"arcCenter X " + arcCenterX + "\n" + "arcCenter Y " + arcCenterY + "\n" + "arcRadius " + arcRadius + "\n");
}
}

}



Now how can I find out the properties and methods of getSubObjects().items? I cannot find it documented anywhere and it appears to be hidden in the binary code. Object.keys() doesnt work at the segment level.
  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:  pressure (PEER)
11540.8 In reply to 11540.7 
Hi Probotix,

Re:
> how can I find out the properties and methods of getSubObjects().items?

That's called a CurveSegment and all the methods and and properties are listed in the API:

https://moi3d.com/forum/index.php?webtag=MOI&msg=10857.36

Re:
> Object.keys() doesnt work at the segment level.

There's a dump function in the Hints section near the top of the API to do that.

- Peer
  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:  Michael Gibson
11540.9 In reply to 11540.5 
Hi probotix,

re:
> Okay, maybe I dont understand how SavePointFile works. If I create just raw points,
> it works fine. But what I want to do is find the points of a polyline or curve and
> export those points.

Yes SavePointFile will only export point objects, not "edit points".

To export those you can convert selected curve edit points to point objects by copy/paste (ctrl+c/ctrl+v).

In v5 it's also possible to access the edit points by script, that would go like this:

var numpoints = crv.numEditPoints;
for ( var i = 0; i < numpoints; i++ )
{
    var pt = crv.getEditPoint( i );
    // use pt.x, pt.y, pt.z
}

- Michael
  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:  probotix
11540.10 In reply to 11540.8 
Can you be more specific about how to use the dump function?
  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:  Michael Gibson
11540.11 In reply to 11540.10 
Hi probotix,

re:
> Can you be more specific about how to use the dump function?

Get the file MoI_v5_API_Documentation.htm from here:
https://moi3d.com/forum/index.php?webtag=MOI&msg=10857.36

That has the code for a dump function, copy the dump function into your script and then you can call dump( obj ); which will list properties of that object.

- Michael
  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:  probotix
11540.12 In reply to 11540.11 
Thanks Michael!

Is there a way to launch Moi from a console and print debug info from my scripts?
  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:  Michael Gibson
11540.13 In reply to 11540.12 
Hi probotix,

re:
> Is there a way to launch Moi from a console and print debug info from my scripts?

Sorry no there isn't a way to print debug info to a system console.

A script can show a dialog box message using moi.ui.alert( 'text' ); or it can also write to MoI's log using moi.log( 'text' ); .

You can show the log using:
moi.ui.createDialog( 'ShowLog.htm' );

- Michael
  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