MoI discussion forum
MoI discussion forum

Full Version: MOI3d CAM Alpha version

From: nemoz
6 Nov   [#1]
Hi Michael,

Issues with Object Selection in Custom HTML Commands & 3D Development Inquiry

Dear MoI 3D Developer,

I am currently developing custom HTML commands for MoI 3D, specifically focusing on CAM functionalities.
I've encountered a critical and persistent issue regarding object selection within the JavaScript context of
these HTML commands.

Problem Description: Object Selection in HTML Commands

Despite visually selecting objects (e.g., a face of a solid, or a standalone planar surface) in the MoI
viewport, my JavaScript code within the HTML command consistently fails to recognize these selections.

I have attempted the following methods:

1. `window.parent.moi.geometryDatabase.getObjects()` and iterating to check `obj.selected`: When iterating
through all objects returned by getObjects(), the obj.selected property for the visually selected object(s)
always returns false.
2. `window.parent.moi.geometryDatabase.getSelectedObjects()`: This method consistently returns an empty
collection (length is 0), even when objects are visibly selected.
3. `window.parent.moi.geometryDatabase.getLastSelectedObject()`: This method appears to be undefined or
inaccessible in my environment, resulting in a TypeError.

This behavior is highly unusual for a JavaScript API interacting with a CAD environment. It prevents any CAM
operation that relies on user selection from functioning correctly. Could you please clarify the correct and
reliable way to retrieve the currently selected object(s) (including faces of solids and standalone
surfaces) from within a custom HTML command's JavaScript? Is there a specific event, method, or context I
should be using to ensure the selection state is correctly propagated to the HTML command's environment?

Forward-Looking Inquiry: 3D Solid Selection and Dimension Retrieval

Looking ahead, I plan to develop more advanced 3D CAM functionalities, which will require robust interaction
with solid models. To facilitate this, I would greatly appreciate information on:

* Reliable selection of 3D solid objects: Beyond faces and surfaces, how can I reliably select and identify
entire solid objects within the JavaScript API?
* Retrieving dimensions and properties of 3D solids: Once a solid is selected, what are the appropriate API
methods to obtain its bounding box, volume, surface area, or other geometric properties necessary for CAM
calculations?

Having this information would be invaluable for the continued development of these advanced features.

Thank you for your time and assistance. I look forward to your guidance on these critical points.

I can already obtain gcode for profiling, drilling, threading, pocketing on zxc machines, on top face and on side faces, and even on normal xyz machines... can you please give me some suggestions?

thanks

Nemoz
From: Michael Gibson
6 Nov   [#2] In reply to [#1]
Hi Nemoz,

re:
> Could you please clarify the correct and reliable way to retrieve the currently selected object(s)
> (including faces of solids and standalone surfaces) from within a custom HTML
> command's JavaScript?

It's moi.geometryDatabase.getSelectedObjects().

If that is not working for your script, please post the script and .3DM file, or send it to me at moi@moi3d.com so I can try to reproduce the problem over here.


> Retrieving dimensions and properties of 3D solids: Once a solid is selected, what are the appropriate API
> methods to obtain its bounding box, volume, surface area, or other geometric properties necessary for CAM
> calculations?

For getting a bounding box:
var bbox = obj.getBoundingBox( true /* Use high accuracy bounds */ );

Bounding box has these properties:

bbox.min
bbox.max
bbox.center
bbox.xLength
bbox.yLength
bbox.zLength
bbox.diagonalLength


Calculating surface area:
code:
function GetObjectArea( objects )
{
	moi.geometryDatabase.deselectAll();
	objects.setProperty( 'selected', true );

	var area = moi.ui.propertiesPanel.calcSurfaceArea();
	moi.geometryDatabase.deselectAll();

	return area;
}

Calculating volume:
code:
function GetObjectVolume( objects )
{
	moi.geometryDatabase.deselectAll();
	objects.setProperty( 'selected', true );

	var volume = moi.ui.propertiesPanel.calcSolidVolume();
	moi.geometryDatabase.deselectAll();


	return volume;
}


- Michael
From: nemoz
13 Nov   [#3] In reply to [#2]
So ... a lot of coding and finally I'm very close to the end... Attached you can find the manual, 2 axes operations already tested and even lathe operations and 3 axes operations, now I will start the testing for 4 axes operations... 5 axes operations can't be tested because I don't have yet a 5 axes machine, I can only import in a gcode 5 axes simulator . As soon as I will be sure that everything is done I will release it.

Attachments:
MOI3DCAM_manual_v0.1.pdf


From: blowlamp
13 Nov   [#4] In reply to [#3]
It looks like an epic piece of work.
I'm looking forward to testing this with my PlanetCNC controlled lathe.
Thanks for the all the effort you must have put into it.

Martin.
From: nemoz
14 Nov   [#5] In reply to [#4]
are you using windows based pc?
From: blowlamp
14 Nov   [#6] In reply to [#5]
Yes. I'm staying with Windows 10 for as long as posible. ;-)

Martin.
From: nemoz
15 Nov   [#7] In reply to [#6]
I don't want to know which cam you are using actually, but can you spot a postprocessor in that list that fit your machine? I used this type of postprocessors because this is the biggest postprocessor library downloadable for free.
https://mecsoft.com/downloads/download-posts/
We can even make one from zero in case... I'm finishing the GUI to create post processors...
From: blowlamp
15 Nov   [#8] In reply to [#7]
I have a Mach 3 controlled milling machine as well as a PlanetCNC lathe, both of these use a very similar g-code structure which is mostly interchangeable. The PlanetCNC controller can use g-code written for a LinuxCNC machine, so there is nothing unusual to allow for there.

Martin.
From: AlexPolo
15 Nov   [#9]
Wow amazing a long time RHINO CAM paired with a SHOPBOT PRS5 with 5th axis on windows 10 been solid for nearly 20 years,
Look forward to the release and costings?