-
Posts
2,870 -
Joined
-
Last visited
-
Days Won
6
Content Type
Profiles
Forums
Downloads
Store
eMastercam Wiki
Blogs
Gallery
Events
Posts posted by Roger Martin from CNC Software
-
-
Quote
Can the .FT files also be located in this "custom" folder also?
NO.
The .FT (Function Table) files must be located in Mastercam's \chooks folder.
Your add-in DLLs can be located wherever you wish, as the the data in the .FT file tells Mastercam where to find it.
-
Peter,
STL Container -> Use them.
Zaffin's statement here are words of wisdom.
11 hours ago, Zaffin said:A (very) wise women once said "If you don't know what type of container you need, use a vector".
If you take advantage of lambdas and iterators you can likely measure the performance between any of the STL containers just by changing the type.
-
Peter,
QuoteI hope we will be seeing more projects to come!
If you have project suggestions, send them to us. - SDK[at]mastercam[dot]com
-
Not to discourage you, as Peter will tell you, a C++\CLI Add-In is a very flexible and powerful way to go.
But, I would not consider this a C++ beginner project.
If you email me SDK[at]mastercam[dot]com]
Company contact info and details of what you're trying to have your add-in do, I can take a look .
-
Right now, you cannot using the NET-Hook API.
There is this item in our backlog about this functionality -
[S-41011] : NET-Hook API - Add support for creating/manipulating Geometry GroupsAre you familiar with C++ programming?
Could create a C++/CLI "worker" DLL that your NET-Hook project references and calls to do this work.
What version of Mastercam are you running?
-
Pete,
I have no idea what you have going on here. The constructor error make no sense.
To be sure that the code in the previous post was not mangled, I copied that code directly from that post to a C++/CLI project (that references the NETHook API).
And... It builds, runs and produces the expected result. Tested in Mastercam 2018 and 2020.
Expanding it out to include processing of Surfaces/Solids may be a bit more involved.
To see exactly what the "type" you're dealing with, add some diagnotics.
auto gt = selectedEnts->GetType ();
System::Diagnostics::Debug::WriteLine ("gt=> " + gt->ToString ());
if (gt == pointType) {...} -
Try this.
/// <summary> Get the selected wireframe geometry by type. </summary> /// /// <param name="points"> [out] The points. </param> /// <param name="lines"> [out] The lines. </param> /// <param name="arcs"> [out] The arcs. </param> void SelectedWireframeGeometryByType ( System::Collections::Generic::List<Mastercam::BasicGeometry::PointGeometry ^> ^points, System::Collections::Generic::List<Mastercam::Curves::LineGeometry ^> ^lines, System::Collections::Generic::List<Mastercam::Curves::ArcGeometry ^> ^arcs) { auto pointType = Mastercam::BasicGeometry::PointGeometry::typeid; auto lineType = Mastercam::Curves::LineGeometry::typeid; auto arcType = Mastercam::Curves::ArcGeometry::typeid; auto selectedEnts = Mastercam::Support::SearchManager::GetSelectedGeometry (); // Iterate through each wireframe entity for (auto i = 0; i < selectedEnts->Length; i++) { auto gt = selectedEnts[i]->GetType (); if (gt == pointType) { // dynamic_cast here is like the "as" keyword in C# points->Add (dynamic_cast<Mastercam::BasicGeometry::PointGeometry ^> (selectedEnts[i])); } else if (gt == lineType) { lines->Add (dynamic_cast<Mastercam::Curves::LineGeometry ^> (selectedEnts[i])); } else if (gt == arcType) { arcs->Add (dynamic_cast<Mastercam::Curves::ArcGeometry ^> (selectedEnts[i])); } } } void TestGetByType () { auto points = gcnew System::Collections::Generic::List<Mastercam::BasicGeometry::PointGeometry ^> (); auto lines = gcnew System::Collections::Generic::List<Mastercam::Curves::LineGeometry ^> (); auto arcs = gcnew System::Collections::Generic::List<Mastercam::Curves::ArcGeometry ^> (); SelectedWireframeGeometryByType (points, lines, arcs); auto msg = System::String::Format ("{0} - Points\n{1} - Lines\n{2} - Arcs", points->Count, lines->Count, arcs->Count); System::Diagnostics::Debug::WriteLine (msg); // Using the 'native' MessageBox here just so that we don't need to reference System::WindowsForms. MessageBox (nullptr, CString (msg), _T ("Wireframe Geometry"), MB_ICONINFORMATION); }
-
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>
- 1
-
NET-Hook API Reference Guide
https://nethookdocs.mastercam.comSearch for: "DrillPoint"
See: DrillPoint Constructor (ArcGeometry)In a "Point-Based" type operation in the NET-Hook API...
The toolpath geometry assigned to it are "DrillPoint" objects.
The operation has the "DrillPoints" member data that contains these points.-Pseudo code-
// MyArc - is an existing ArcGeometry object.
// MyDrillOp - is a "Point-Based" type operation.var drillPt = new DrillPoint(MyArc);
MyDrillOp.DrillPoints.Add(drillPt);
MyDrillOp.Commit();
MyDrillOp.Regenerate();
-
Peter,
See :
NET-Hook API Reference Guide
https://nethookdocs.mastercam.comSearch for: OperationsManager.ImportOperation
Note the ImportOptions that are passed to the ImportOperation method.
-
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"?
-
OK...
You're trying to chain what, on which level, while having the chaining ignore what type(s) of geometry?
You're said you're doing this by blanking the unwanted entities, which while this will work...
You don't like the need to have to call rebuild_graphics after. Fair enough, as that can take some time to complete.
There may be other ways to segregate the wanted from the unwanted geometry when chaining.
If I have details, I may be able to offset suggestions,
-
Can you email me a sample part file? SDK [at] mastercam [dot] com
Just a sample of the geometry you're dealing with and let me know which items should be chained and which should be ignored.
Since you doing C++/CLI you have all of the tools available to you.
-
Quote
could the call set_clr_sel_bits() be interfering
Depends if you're messing with the BLANK_BIT when using this.
So you are "blanking" the items you don't want included in the chain(s) and then chaining all on that level?
QuoteIn order to avoid inadvertently chaining existing geometry on the target levels
Is that the only way you have to separate the items to be chained?
Can you separate the desired items - by type, by color, or...
-
Did you use repaint_graphics or rebuild_graphics ?
In my simple testing (of just a single arc) I did not need use either of them. -
The now un-blanked entities are not appearing visually on-screen?
ref: interfaces\GUI\CGui_ch.h
// Try this first after the un-blanking.
repaint_graphics ();// This 'repaint_graphics' does do it for you, replace it with this ->
rebuild_graphics(); // Only use if really needed, as this can take time.} while (succf); if (suc) // Was anything changed? repaint_graphics (); return suc ? 1 : 0;
-
Not sure what you mean about "does not work".
This worked for me (tested in 2018 and 2020) ->
extern "C" __declspec (dllexport) int m_main (int not_used) { // Must call this prior to accessing any Resources in the C-Hook DLL ! ChangeResCl res (GetChookResourceHandle ()); ent entity; if (AskForGeometry (_T ("Select an Arc..."), A_ID, entity)) { sel_bit_turn_on (&entity, BLANK_BIT); write_ent_sel (&entity, entity.eptr); AfxMessageBox (_T ("Entity was Blanked")); sel_bit_turn_off (&entity, BLANK_BIT); write_ent_sel (&entity, entity.eptr); AfxMessageBox (_T ("Entity was UnBlanked")); } return MC_NOERROR | MC_UNLOADAPP; }
-
Quote
without create any additionnal geometry, the canonic datas of a solid edge?
No, not with the NET-Hook API and even with a C-Hook type add-in I believe you would need to create the Edge in order to get that data.
-
JonRob,
I assume you're the one I am corresponding with via email.
Check your mail.
-
I think this may be what you are looking for.
If not, email us: Your code sample file and company contact info to > SDK [at] mastercam [dot] com
As you see in the View data for the arc you have the ViewNumber of the selected arc. You can use that View Number data.
// arc = the user selected arc
var ctr = ViewManager.ConvertToWorldCoordinates(arc.Data.CenterPoint, arc.ViewNumber);
// Use this as the center point for the new arc...NET-Hook API Docs - https://nethookdocs.mastercam.com
See in Mastercam.IO.ViewManager:
Point3D ConvertToViewCoordinates(Point3D WorldCoordinates, short ViewNumber)
Point3D ConvertToViewCoordinates(Point3D WorldCoordinates, short ViewNumber)
Point3D ConvertToWorldCoordinates(Point3D ViewCoordinates, MCView View)
Point3D ConvertToViewCoordinates(Point3D WorldCoordinates, MCView View)
-
I am not sure what you mean be "exotic" views.
Mastercam has Named Planes (views). Those are displayed in the Planes Manager pane in Mastercam.
ViewManager.GetAllViews(False) retrieves ALL of these known views.
The arc you have the user select contains ViewNumber data of the view that arc is in.
You can work with that value to get all of the Plane (MCView) data for the arc’s view if needed.
-
Something to try.
Note that it's looking for the Plane (view) with the name of "MyTargetPlane" to use as the to Translate To View.
Private Function TranslateArc() As Boolean Dim entTypeMask = New GeometryMask(False) With { .Arcs = True } ' Ask the user to select a single Arc geometry item. Dim geom = SelectionManager.AskForGeometry("Select Arc", entTypeMask) If geom Is Nothing Then Return False End If ' Cast the Geometry to it's specific type. ' We know it's an Arc, so this direct-cast is safe. Dim arc = CType(geom, ArcGeometry) ' Get ALL MCView (Planes) data in the file. Dim allViews = ViewManager.GetAllViews(False) ' Search for the destination view "by name". Dim targetView = New MCView() Dim found = False For Each view In allViews If String.Compare(view.ViewName, "MyTargetPlane", StringComparison.OrdinalIgnoreCase) = 0 Then targetView = view found = True Exit For End If Next If Not found Then Return False End If ' Create a new Arc and the same center point as the selected arc in Top. Dim topView = SearchManager.GetSystemView(SystemPlaneType.Top) Dim arcSup = New ArcGeometry(topView.ViewNumber, New Point3D(0, 0, 0), 15.0, 0.0, 360.0) arcSup.Commit() ' The center point of the selected arc in world coordinates. Dim ptWorldCoordinates = ViewManager.ConvertToWorldCoordinates(arc.Data.CenterPoint, arc.ViewNumber) ' Translate this new arc to the "MyTargetPlane" view. Return arcSup.Translate(New Point3D(0, 0, 0), ptWorldCoordinates, topView, targetView) End Function
-
Quote
chains_intersect function requires an active machine group
Yes, if there is no Machine Group(s), it will return '-1' (error).
-
Peter,
Is Mastercam in "Design" mode when executing - chains_overlap_pct (...) ?
You need to have at least a Machine Group so Mastercam is not in Design.
Otherwise it will always return 0 in the (2) out variables.
Chook Question : Simplify Spline
in Mastercam C-Hook, NET-Hook and VBScript Development
Posted
Converting a single Spline to a single arc?
-or-
Simplifying a Spline to possibly multiple arcs and/or lines?