Sign in to follow this  
Compaq007

Chook for Converting a 3D point coordinates

Recommended Posts

Hello All,

I had been playing around with visual scripting for MasterCAM 2017 for some time and learning the language as best as I can, but I have a lot learn yet, and recently ran into a challenge:

Converting a 3D point coordinates from Top View to my current View is not supported under visual script.

Looks like some C# work is needed here, which by the way I am a fan of but have cero experience, so I decided to take a look anyways.

For a couple of day I have been dissecting sample C# projects and realized that I am far from understanding the C# language then I figure that is best to reach out for help.

I was wondering if can get someone's assistance in creating a Chook application that can be invoked from a VisualScript, pass the 3D point coordinates (x,y,z), along with the view number to have the application return converted coordinates values for x,y,z. back to the VisualScript.

I am open to suggestions of course.

Thank you for the help in advance. Happy new year.

 

Share this post


Link to post
Share on other sites

Check out this recent post : Link you can covert the code into c# using telerik.com code converter. It should help you get started.

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
Quote

...visual scripting for MasterCAM

Forget about VB Scripting in Mastercam, as no further development will be happening with the old style VBScript support within Mastercam.
You want to develop your add-in using the NET-Hook API (C#, VB.NET) or the the C-Hook SDK (C++, C++/CLI).

Quote

...pass the 3D point coordinates (x,y,z), along with the view number to have the application return converted coordinates values for x,y,z.

So, you are basically translating the points "between views"?
 

Edited by Roger Martin from CNC Software

Share this post


Link to post
Share on other sites
52 minutes ago, Roger Martin from CNC Software said:

Forget about VB Scripting in Mastercam, as no further development will be happening with the old style VBScript support within Mastercam.
You want to develop your add-in using the NET-Hook API (C#, VB.NET) or the the C-Hook SDK (C++, C++/CLI).

So, you are basically translating the points "between views"?
 

NET-Hook API C#, is where I will focus.

Yes, that is correct, translating the points in order to get the x,y and z coordinates related to the target view.

Share this post


Link to post
Share on other sites

Where at the “source” points coming from?
Are you having the user select the Point geometry entities to be translated?
Or, are you going to have your add-in do this selecting?
Once you have the “source” points you could translate them it a couple ways…

In the Mastercam.IO.ViewManager class you have multiple overloads of these methods ->
ConvertToWorldCoordinates and ConvertToViewCoordinates
You could convert the coordinate data for each source point using ConvertToWorldCoordinates.
Then convert that new (world) point into the desire target view using ConvertToViewCoordinates.
-or-
In the Mastercam.GeometryUtility.GeometryManipulationManager class you have the TranslateGeometry method.
 

/// <summary> XForm-Translate all the 'selected' geometry entities. </summary>
///
/// NOTE!
/// Any Geometry objects that get altered will NOT be reflected in that entity's data
/// "on the NET-Hook side" if that entity's data is being held in a NET-Hook Geometry object! 
/// You can use SearchManager.GetResultGeometry to retrieve the result of the XForm operation. 
/// If a supplied view is null, the active Construction View will be used.
/// If there was no 'selected' geometry found to be XForm'd, the return result will be 'true'.
/// Also note that all 'selections' will be cleared by the XForm operation.
///
/// <param name="FromPoint"> The 'from' point (in world coordinates). </param>
/// <param name="ToPoint"> The 'to' point (in world coordinates). </param>
/// <param name="FromView"> The 'from' view. </param>
/// <param name="ToView"> The 'to' view. </param>
/// <param name="Copy"> true to copy, else false to move. </param>
///
/// <returns> true if it succeeds, false if it fails. </returns>

 

  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, Roger Martin from CNC Software said:

Where at the “source” points coming from?
Are you having the user select the Point geometry entities to be translated?
Or, are you going to have your add-in do this selecting?
Once you have the “source” points you could translate them it a couple ways…

In the Mastercam.IO.ViewManager class you have multiple overloads of these methods ->
ConvertToWorldCoordinates and ConvertToViewCoordinates
You could convert the coordinate data for each source point using ConvertToWorldCoordinates.
Then convert that new (world) point into the desire target view using ConvertToViewCoordinates.
-or-
In the Mastercam.GeometryUtility.GeometryManipulationManager class you have the TranslateGeometry method.
 

/// <summary> XForm-Translate all the 'selected' geometry entities. </summary>
///
/// NOTE!
/// Any Geometry objects that get altered will NOT be reflected in that entity's data
/// "on the NET-Hook side" if that entity's data is being held in a NET-Hook Geometry object! 
/// You can use SearchManager.GetResultGeometry to retrieve the result of the XForm operation. 
/// If a supplied view is null, the active Construction View will be used.
/// If there was no 'selected' geometry found to be XForm'd, the return result will be 'true'.
/// Also note that all 'selections' will be cleared by the XForm operation.
///
/// <param name="FromPoint"> The 'from' point (in world coordinates). </param>
/// <param name="ToPoint"> The 'to' point (in world coordinates). </param>
/// <param name="FromView"> The 'from' view. </param>
/// <param name="ToView"> The 'to' view. </param>
/// <param name="Copy"> true to copy, else false to move. </param>
///
/// <returns> true if it succeeds, false if it fails. </returns>

 

I am planning to have the user pick a point using the Visual Script from MasterCAM interface then pass the x,y & z info to the net-hook and have the net-hook do the translation then return the values back to the Visual Script.. I know, i said that the Nethook will be my focus, and it will, but right now that is a big complication for me since i am "Nethook challenged" and I do have other Visual Script functions tied to the same script.

I am not sure how difficult this is or if it is even possible, and I am wondering if it would be easier to have the net-hook do the point selection?

What a way to begin the new year, right?

Btw. All the help is very much appreciated. 

 

 

Share this post


Link to post
Share on other sites
4 hours ago, Compaq007 said:

I am planning to have the user pick a point using the Visual Script from MasterCAM interface then pass the x,y & z info to the net-hook and have the net-hook do the translation then return the values back to the Visual Script..

The easiest way to do this would be to store the information in a text file with your nethook then read it with vbscript after the fact. You can execute a nethook from vbscript using the RunFtCommand Function.

  • Like 1

Share this post


Link to post
Share on other sites
15 hours ago, Compaq007 said:

I am planning to have the user pick a point using the Visual Script from MasterCAM interface then pass the x,y & z info to the net-hook and have the net-hook do the translation then return the values back to the Visual Script..

 

 

This sounds like alot more work than just using a NET-Hook to do everything.

I threw together a quick sample last night; it should give you an idea of what's possible.

And even though I think you should use a NET-Hook to do this, if you can get a view's matrix in VBScript you can map a point.  Multiplying a point's X, Y, and Z by view's matrix will give you the X, Y, and Z relative to that view.

  • Like 2

Share this post


Link to post
Share on other sites
10 hours ago, Zaffin said:

This sounds like alot more work than just using a NET-Hook to do everything.

I threw together a quick sample last night; it should give you an idea of what's possible.

And even though I think you should use a NET-Hook to do this, if you can get a view's matrix in VBScript you can map a point.  Multiplying a point's X, Y, and Z by view's matrix will give you the X, Y, and Z relative to that view.

this is good stuff!, great example, Zaffin,. I totally overlooked the matrix multiplication..

I agree with you, I will eventually do all of these in a NET-Hook application.

I appreciate all the pointers and everybody's help. I will keep updating on my progress and share the final product, eventually.

Thank you all.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us