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:

Mirror with VB script


Recommended Posts

I am making a VB script for version 9.1 and I need to mirror in the script without hard-coding "xfmmir" and asking the user for entities. Is their a code in the script that I can use to mirror without any user input. I need to mirror two levels with different colors on each level. I think I can get the selection code to work if I could get a function to mirror. If I could override the user prompt for entitiy selection I could still use the hard code and select what I need in the script in a sub. I also would like to have a "full" list of functions to use in Mastercam script. The html that comes with the software is lacking functions that I have seen in some of the sample programs. If anyone has this PLEASE post it on the FTP. Thanks for any help.

Link to comment
Share on other sites

There's no way to use the mirror (among many others) functionality itself; only the one that uses the dialog via the RunMastercamCommand() sub. You'll have to manually mirror the entities yourself. It would look similar to this:

 

code:

Call Main()

 

Sub Main()

Dim iCurr ' entity pointer

Dim bSuccf ' success flag

Dim objLine ' McLn object

Dim objArc ' McAr object

Dim objPoint ' McPt object

Dim iLvl ' level of the current entity

Dim iColour ' colour of the current entity

 

 

' Start searching the database by getting the first entity.

bSuccf = StartDBSearch(mc_alive, mc_arctype Or mc_pointtype Or mc_linetype)

 

' Loop through the database of entities and manually mirror and you see fit.

Do While bSuccf

' Get the current entity pointer.

iCurrEnt = GetEntityEptr()

iLvl = GetEntityLevel()

iColour = GetEntityColor()

 

Select Case GetEntityType

Case mc_linetype

Set objLine = New McLn

 

If GetLineData(iCurrEnt, objLine) Then

' Mirror line about the axis of your choosing.

End If

 

Case mc_arctype

Set objArc = New McAr

 

If GetArcData(iCurrEnt, objArc) Then

' Mirror arc about the axis of your choosing.

End If

 

Case mc_pointtype

Set objPoint = New McPt

 

If GetPointData(iCurrEnt, objPoint) Then

' Mirror point about the axis of your choosing.

End If

End Select

 

' Get the next entity.

bSuccf = NextDBSearch()

Loop

End Sub

Since you're looking for certain levels and colours, you'd want to put that SELECT inside of some logic, like an IF, to only do so when the current entity matches the colour and level that you want.

 

quote:

I also would like to have a "full" list of functions to use in Mastercam script.


Since you're running V9, you're in luck. Take a look at McLangDef.csv in the root of your Mastercam directory (Ex: C:Mcam9McLangDef.csv). I've found more in there than in VBScript.htm.

 

quote:

The html that comes with the software is lacking functions that I have seen in some of the sample programs


Tell me about it mad.gif

Link to comment
Share on other sites

Thanks Bullines. I've been teaching myself VB as I go trying new things each time and using examples for refrence. I am making a script to layout geometry on a flat piece of steel for the manual mill guys to follow when roughing. I have a spring loaded pointer in a mill and I need to scribe the shape on several pieces per job. I use color and level to determine which piece gets which geometry. I have my script made to : ask for file/ change levels by entity color/ (I need mirror here for two levels only)/ toolpath one op per level with group name/ post each op to a seperate program with it's own nci destination(still working on nci)/ save file when done. I have been writing subs and then adding to the program as I go. Mick's examples in the VB folder of V9 have been a big help.

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