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:

change color lines - surfaces on nethook2


Recommended Posts

Hi

 

With the first nethook to change the color of arcs, lines and points I was usually to follow this procedure:

 

 

' -- Mask on all alive arcs, lines and points

Do While DataBase.DBSearch(search_idx, found_idx, MC_SELBIT.Alive, MC_ENTMASK.Solid_ID)

 

' -- Set flag, gets set for each iteration but who cares ;)

bFound = True

 

' -- Get the current ent from its id

Dim Obj As Object = DataBase.GetEnt(found_idx)

Dim ThisEntRef As New CEntRef(found_idx)

 

'Mastercam.GUI.SetCPlaneNumber(2) ' piano di costruzione obbligatorio metterlo

'setto il colore 10 - verde -

DataBase.SetEntColor(found_idx, 8)

 

'ruota

' Mastercam.XForm.Rotate(ThisEntRef, True, punto, ruota, 2)

 

' -- clean up, not really needed but it makes me feel better

'ThisPoint = Nothing

ThisEntRef = Nothing

 

Loop

With the new version (nethook 2 X5) as I can make a loop on all the entities 'to change the properties'? Do you have any example?

 

Thank you for the cooperation.

 

Nevio

Link to comment
Share on other sites

Here is how to 'GetGeometry' and loop thru thelist making changes to the entities that were found

 

C# code ->

 

// Initialize to select nothing
Mastercam.Database.Types.GeometryMask geoMask = new Mastercam.Database.Types.GeometryMask(false);
geoMask.Solids = true; // But we do want Solids

// Initialize to select none
Mastercam.Database.Types.SelectionMask selMask = new Mastercam.Database.Types.SelectionMask(false);
selMask.All = true; // All 'alive' entities

int level = -1; // We can also restrict the search to a level (-1 means ALL levels)

Mastercam.Database.Geometry[] geometry = Mastercam.Support.SearchManager.GetGeometry(geoMask, selMask, level);
foreach (var item in geometry)
{
 item.Color = 12; // Set the Color of this entity
 item.Commit();   // Commit the change to the database
}

 

 

Here is is in VB.NET

 

Auto translation from C# -> VB.NET

 

' Initialize to select nothing
Dim geoMask As New Mastercam.Database.Types.GeometryMask(False)
geoMask.Solids = True ' But we do want Solids

' Initialize to select none
Dim selMask As New Mastercam.Database.Types.SelectionMask(False)
selMask.All = True ' All 'alive' entities

Dim level As Integer = -1 ' We can also restict the search to a level (-1 means ALL levels)
Dim geometry As Mastercam.Database.Geometry() = Mastercam.Support.SearchManager.GetGeometry(geoMask, selMask, level)
For Each item As var In geometry
item.Color = 12 ' Set the Color of this entity		
item.Commit() ' Commit the change to the database
Next

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...