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:

VBS & Moving Levels


Recommended Posts

Good Afternoon All,

 

When I import a DXF it seems to always import onto layer 7. Standard practice here is to then move the imported geometry into layer 6. I have written a little VB Script that doesn't seem to be working quite right.

 

It imports, Toggles Layer 1 off (stuff I don't want to move on that layer), and selects all.

From my digging the "Call SetEntityLevel(6)" line should move the stuff to layer 6 but it doesn't seem to be working.

 

Also, after moving, what do I call to delete/remove layer 7?

 

Any pointers?

 

Thanks in advance!

James

Sub ImportDXF() If RingType = 2 then  ShowString("Select DXF File")  Runmastercamcommand "DoPattern" End if  Call SetLevelVisibleByNumber(1, False) SelectAll Call SetEntityLevel(6) Call RepaintScreen(True) UnselectAllEnd Sub
Link to comment
Share on other sites

Good Morning,

 

Could you attach your script and a file and I will take a look,

 

Thanks

 

 

Good Afternoon All,

 

When I import a DXF it seems to always import onto layer 7. Standard practice here is to then move the imported geometry into layer 6. I have written a little VB Script that doesn't seem to be working quite right.

 

It imports, Toggles Layer 1 off (stuff I don't want to move on that layer), and selects all.

From my digging the "Call SetEntityLevel(6)" line should move the stuff to layer 6 but it doesn't seem to be working.

 

Also, after moving, what do I call to delete/remove layer 7?

 

Any pointers?

 

Thanks in advance!

James

Sub ImportDXF() If RingType = 2 then  ShowString("Select DXF File")  Runmastercamcommand "DoPattern" End if  Call SetLevelVisibleByNumber(1, False) SelectAll Call SetEntityLevel(6) Call RepaintScreen(True) UnselectAllEnd Sub
Link to comment
Share on other sites

Good Morning,

 

Could you attach your script and a file and I will take a look,

 

Thanks

 

Sub ImportDXF()

If RingType = 2 then

ShowString("Select DXF File")

Runmastercamcommand "DoPattern"

End if

 

Call SetLevelVisibleByNumber(1, False)

SelectAll

Call SetEntityLevel(6)

Call RepaintScreen(True)

UnselectAll

End Sub

Link to comment
Share on other sites

SetEntityLevel sets the level of an entity.

​You have not told it which entity to alter.

You need to run through the entities that you've 'selected' and change them.

'////////////////////////////////////////////////////////////////////////////////
'// File Name:  MoveToLevel.vbs
'// Date:       02/19/2016
'//
'// Description:   
'// This script demonstrates changing the Level of entities.
'// So we are "moving" all entities (that are NOT on Level #1) to Level #6 
'//
'//////////////////////////////////////////////////////////////////////////////// 
Const DEF_GIVE_ME_EVERYTHING = -1

' -- Start Script
Call Main()

' ////////////////////
' Sub Declaration
' ////////////////////
Sub Main()   

Dim bRet

' Turn off Level #1 so we do NOT select anything on this level
Call SetLevelVisibleByNumber(1, False)

' This selects all "visible" entities
SelectAll

' Run through the database looking for selected entities
bRet = StartDBSearch(mc_selected, DEF_GIVE_ME_EVERYTHING)

If bRet Then
Do 
 ' Change the level on each "selected" entity that we find. 
  Call SetEntityLevel(6) 
  bRet = NextDBSearch    
  Loop While bRet  
End If

' Like is says...
UnselectAll

' Here we assume that the data we "moved" was on Level #7
' So we want to remove that level from the levels list.
' Usually we do not need to do anything as the level has no entities, but...
' If a level has a name, Mastercam will not auto-purge it as an empty level
Call SetLevelName (7, "")

' Refresh (and FIT) the graphics display
Call RepaintScreen(True)

End Sub

Edited by Roger Martin from CNC Software
  • Like 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...