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:

Create Entities Groups C#


Recommended Posts

I'm checking that this forum has little movement.

There are several unanswered questions of mine. I imagine the same thing would happen with this one, but just in case here's the question.

Is there a way to create groups or lists of entities (arcs, lines, points...) and be able to call them to use them when needed? in case I want to move or copy them.

Thank you all for the answers.

Link to comment
Share on other sites
4 hours ago, eltklas said:

I'm checking that this forum has little movement.

There are several unanswered questions of mine. I imagine the same thing would happen with this one, but just in case here's the question.

Is there a way to create groups or lists of entities (arcs, lines, points...) and be able to call them to use them when needed? in case I want to move or copy them.

Thank you all for the answers.

hi eltklas,

i don't visit this forum that often, usually i go on the mastercam official forum,

here is an example of adding an arc to a list and translating it

using System;
using System.Collections.Generic;
using Mastercam.Database;
using Mastercam.Curves;
using Mastercam.Math;
var topView = Mastercam.IO.ViewManager.GetAllViews(false)[0];

var point = new Point3D(0.0,0.0,1.0);//lets say we created a point at z 1.0
var radius = 0.5;
var arcs = ArcCreator.CreateArc(topView,point,radius);

var fromView = topView;//translate from top view
var toView = topView;//translate to top view (for simplicity)
var fromPoint = new Point3D(0.0,0.0,0.0);//translate from 0
var toPoint = new Point3D(1.0,0.0,0.0);//translate to 1
bool copy = false;//true to copy



//lets say you executed some code here


//...your code



//now lets select the geometry and commit it then translate
foreach(var myarc in arcs)
{
	
        myarc.Selected = true;//sel bit turn on

        // Commit the arc to select it
        myarc.Commit();//rewrite_ent
}
Mastercam.GeometryUtility.GeometryManipulationManager.TranslateGeometry(fromPoint,toPoint,fromView,toView,copy);
public class ArcCreator
{
    // Method to create an arc and return a list of created arcs
    public static List<ArcGeometry> CreateArc(MCView view, Point3D point, double radius)
    {
        // List to store created arcs
        var arcList = new List<ArcGeometry>();

        // Create a new arc with specified parameters
        var arc = new ArcGeometry
        {
            View = view,
            ViewNumber = view.ViewNumber,
            Data =
            {
                CenterPoint = point,
                Radius = radius,
                StartAngleDegrees = 0.0,
                EndAngleDegrees = 360.0
            },
            Selected = false,
            Color = 9
        };

        // Commit the arc and add to list
        arc.Commit();
        arcList.Add(arc);

        // Return the list of created arcs
        return arcList;
    }
}

 

  • Thanks 1
Link to comment
Share on other sites
On 4/22/2024 at 3:03 AM, eltklas said:

I have requested access to that forum, I am waiting for It.

Thanks for answer. Must the list have only arcs? Can I have more type of entities?

Thans again.

sure if you want to store multiple types in List<> the best way is to store the entity ids as long (or int for .NET :rolleyes:

to get the id you call GetEntityID(), then retrieve it using the Mastercam.Support.SearchManager function for retrieving the entity by id

  • Thanks 1
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...