Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Geometry Error


Recommended Posts

23 minutes ago, x4g said:

There is a new Mastercam Project Template that will create a chook-InteropDll and c# project like what you are used to, this will make it easier to manage your c++ code

How new is this? And where is it?

It looks like I have lost access to the SDK Downloads, C-Hook downloads, and NetHook downloads 🤷‍♂️

Link to comment
Share on other sites
9 minutes ago, JKLINE said:
Mastercam::CHookAPI::Database::

This was the key to finding the options/tools/methods ect ect. 

I'm still not seeing any 'surface' commands though. Enlighten me?

Ask the Api Team for the relevant chook example to create a ruled/lofted surface, that interface is not exposed to the API

or you can pickup up the definition using the dumplib utility, (see pdf on dumplib in the sdk installer folder)

  • Thanks 1
Link to comment
Share on other sites
11 minutes ago, Roger Martin from CNC Software said:

JKLINE,

You are looking to create a Draft surface with a NET-Hook add-in?

 

Yes.

Take customer geometry
ChainOffsetContour(you've already helped me with this)
DraftSurface(from the Result of ChainOffsetContour) at a negative depth (user specified) and angle (user specified).
All ChainOffsetContour results are closed chains, and climb (Clockwise I think) direction is a positive angle.

On 12/14/2022 at 8:06 AM, JKLINE said:

That's a negative. It's angled at either 10, 15, 20, or 30 degrees at a negative depth.

This here is an example of an end result. White line is the supplied geometry. We offset the green geometry. And then draft a surface down.

Untitled.png

 

White line is customer supplied geometry.

Green is the offsetContour in both directions.

Surface is a draft surface at a negative value.

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

JKLINE,

You are looking to create a Draft surface with a NET-Hook add-in?

 

Using the code below, I'm getting a result, but some things seem strange.

1. It doesn't send the surface to a different level.

2. The angle I type in doesn't seem to matter. 15.0 results in -0.2618 degrees.

3. It follows the chains, but not the arcs.

Did I code it wrong? 😕

            void offsetCutchain(){
                SelectionManager.UnselectAllGeometry();
                LevelsManager.RefreshLevelsManager();
                GraphicsManager.Repaint(true);
                var selectedCutChain = ChainManager.GetMultipleChains("Select Geometry");
                int mainGeo = 10;
                  int roughSurf = 138;
                   SurfaceDraftParams roughSurfaceDraftParams = new SurfaceDraftParams {
                    draftMethod=SurfaceDraftParams.DraftMethod.Length,
                    geometryType=SurfaceDraftParams.GeometryType.Surface,   
                    length=-0.100,
                    angle=15.0,
                    draftDirection=SurfaceDraftParams.DraftDirection.Defined
                    } ;
                foreach (var chain in selectedCutChain){
                    var mainGeoSide1 = chain.OffsetChain2D(OffsetSideType.Right, .002, OffsetRollCornerType.All, .5, false, .005, false);
                    var mainGeoResult = SearchManager.GetResultGeometry();
                    foreach (var entity in mainGeoResult){
                        entity.Color = mainGeo;
                        entity.Level = mainGeo;  
                        entity.Selected = true;
                        entity.Commit();
                    }
                    var thisChain10 = ChainManager.ChainAllSelected();
                    foreach (var draftChain10 in thisChain10) {
                        var draftSurface10 = SurfaceDraftInterop.CreateDrafts(draftChain10, roughSurfaceDraftParams, false, 1);
                        foreach (var surface10 in draftSurface10){
                            if (Geometry.RetrieveEntity(surface10) is DraftSurface roughDraftSurface10) {
                                roughDraftSurface10.Level = roughSurf;
                                roughDraftSurface10.Commit();
                            }
                        }
                    }
                    GraphicsManager.ClearColors(new GroupSelectionMask(true));
                }
            }
            offsetCutchain();
            GraphicsManager.Repaint(true);

 

 

Untitled.png

Link to comment
Share on other sites
On 12/13/2022 at 10:39 AM, Roger Martin from CNC Software said:

 

Don’t know “why” at this point, but it makes a difference.

In -> offsetCutChain80() 

Original:

GraphicsManager.Repaint(true);
int createdUpperLevel = 500;
int createdLowerLevel = 501;
 

image.png.212f3fdd41f564ee7e7b7239b8cc9fd8.png

Altered:
GraphicsManager.Repaint(false); // or remove this call 
int createdUpperLevel = 500;
int createdLowerLevel = 501;

Result ->
image.png.c37defcc75199656b4d42316702bbf0d.png

Yes, you can share the ChainDataInterop project.

This has become a large issue for me. 😕

I've taken all the 'repaint(true)' out of the program that I can. Some of the areas require it to be there, or they do not work.

That being said, if I run two of my NetHooks, no matter the order, geometry gets moved 😕

I've tried added this code before and after each VOID but it's not helping.

            void deSelect()
            {
                var selectedGeo = SearchManager.GetGeometry();
                foreach (var entity in selectedGeo)
                {
                    entity.Retrieve();
                    entity.Selected = false;
                    entity.Commit();
                }
            }

https://github.com/UberGamz/RP-GEN-CREASES
https://github.com/UberGamz/RP-GEN-CUT

They work fine SOLO, but when ran together during one Mastercam session, they mix up geometry.

Link to comment
Share on other sites

You could avoid this issue entirely by simply not using selection

 

                    foreach (var entity in creaseResultGeometryNew)
                    {
                        upperCreaseID.Add(entity.GetEntityID());
                        entity.Color = 10;
                        entity.Level = createdUpperCrease;
                        entity.Commit();
                    }
                    //Moves result geometry

 

instead of 

                    foreach (var entity in creaseResultGeometryNew)
                    {
                        upperCreaseID.Add(entity.GetEntityID());
                        entity.Color = 10;
                        entity.Selected = true;
                        entity.Commit();
                    }
                    //Moves result geometry
                    GeometryManipulationManager.MoveSelectedGeometryToLevel(createdUpperCrease, true);

 

  • Like 1
Link to comment
Share on other sites
        var creaseResultGeometryNew = SearchManager.GetSelectedGeometry();
                        foreach (var entity in creaseResultGeometryNew)
                        {
                            entity.Color = 11;
                            entity.Selected = true;
                            entity.Commit();
                        }

Here you are getting selected geometry, trying to select it again and calling commit()

 

That looks like a mistake, no need to select it again, you selected it already

 

 

  • Thanks 1
Link to comment
Share on other sites
23 minutes ago, techbytesoftware.com said:

You could avoid this issue entirely by simply not using selection

 

                    foreach (var entity in creaseResultGeometryNew)
                    {
                        upperCreaseID.Add(entity.GetEntityID());
                        entity.Color = 10;
                        entity.Level = createdUpperCrease;
                        entity.Commit();
                    }
                    //Moves result geometry

 

instead of 

                    foreach (var entity in creaseResultGeometryNew)
                    {
                        upperCreaseID.Add(entity.GetEntityID());
                        entity.Color = 10;
                        entity.Selected = true;
                        entity.Commit();
                    }
                    //Moves result geometry
                    GeometryManipulationManager.MoveSelectedGeometryToLevel(createdUpperCrease, true);

 

I'm so glad when I write new code, I don't do this anymore 🤣

Works like a champ now.

14 minutes ago, techbytesoftware.com said:
        var creaseResultGeometryNew = SearchManager.GetSelectedGeometry();
                        foreach (var entity in creaseResultGeometryNew)
                        {
                            entity.Color = 11;
                            entity.Selected = true;
                            entity.Commit();
                        }

Here you are getting selected geometry, trying to select it again and calling commit()

 

That looks like a mistake, no need to select it again, you selected it already

 

 

How did you find that so fast?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • 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

×
×
  • Create New...