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:

Using Classes in script


Recommended Posts

Hi all. Can anyone give me a sample of using VBscript to draw a rectangle? From what I see, I need to use the McRe class to define the rectangle, then the entity create function CreateRectangle which somehow uses the data from the McRe.

Do each of the 5 parts of the McRe class need to be defined by input?

 

I'm trying to automate drawing a simple rectangle of user inputed size and depth. Its the first step in trying to make a program that will automatically draw an aluminum box, program it for both top and bottom as seperate setups, post the programs and print a doc sheet. Kinda ambitious for me, but one step at a time!

Link to comment
Share on other sites

John,

 

Is the example below what you are looking for?

 

code:

Call Main

 

 

 

Sub Main

 

Call NewMC(False)

Dim CRect

 

 

Call SetCPlaneNumber(mcVIEW_TOP)

 

Set CRect = New McRe

 

With CRect

 

.X1 = 0

.Y1 = 0

.Z = 0

.X2 = 10

.Y2 = 10

 

End With

 

'######## TOP

If CreateRectangle(CRect, 2 , 10) = mcENTITY_INVALID Then Exit Sub

 

With CRect

 

.X1 = 0

.Y1 = 0

.Z = -10

.X2 = 10

.Y2 = 10

 

End With

 

'######### BOTTOM

If CreateRectangle(CRect, 2 , 10) = mcENTITY_INVALID Then Exit Sub

 

 

Call SetCPlaneNumber(mcVIEW_SIDE)

 

With CRect

 

.X1 = 0

.Y1 = 0

.Z = 0

.X2 = 10

.Y2 = -10

 

End With

 

'######### SIDE 1

If CreateRectangle(CRect, 3 , 11) = mcENTITY_INVALID Then Exit Sub

 

 

With CRect

 

.X1 = 0

.Y1 = 0

.Z = 10

.X2 = 10

.Y2 = -10

 

End With

 

 

'############# SIDE 2

If CreateRectangle(CRect, 3 , 11) = mcENTITY_INVALID Then Exit Sub

 

Call RepaintScreen (True)

 

 

 

 

End Sub

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