×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Skipping parts of a macro

Skipping parts of a macro

Skipping parts of a macro

(OP)
Hi Guys,
If I need to miss part of a macro out how can I do that?
I imagine this is easy for you guys but not for me :(

ie,

if value = 0 then goto10
if value > 0 then goto20

10
string = something
goto30

20
string = something else

30
carry on with the macro

many thanks as always
Alan

RE: Skipping parts of a macro

Hi,

CATIA VBA uses the Select Case...End Select construct...http://www.coe.org/p/fo/et/thread=14001

CODE

'
   Select Case Value
      Case 0
         'Executes these statements when Value is zero
         string = something
      Case >0
         'Executes these statements when Value is greater than zero
         string = somethng else
      Case Else
         'Executes these statements when Value fits none of the above criteria
         string = and now something entirely different
   End Select
'Carry on with macro 

You can also use If...Then...ElseIf...Then...Else...End If

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Skipping parts of a macro

(OP)
Thanks SkipVought :)

RE: Skipping parts of a macro

(OP)
Couldnt get that to work :(
I need to get the value from an input box and when i add the case commands it doesnt show the box ?
Just crashes at Case >0

RE: Skipping parts of a macro

Plz post your code.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Skipping parts of a macro

(OP)
Hi guys,
Sorry for the delay but been away with the family for a break.
This is the code I was playing with, need to get my head around it again but basically it doesn't work :(


'-----------------------------------------------------------------------------------------------------------------------

Sub CATMain()

Dim documents1
Set documents1 = CATIA.Documents

Set Document = CATIA.ActiveDocument

Dim selection1
Set selection1 = Document.Selection

Set Info = selection1.Item(1)

Dim Dimension1
Set Dimension1 = Info.Value
'---------------------------------------------------------------------------------------------------
Dim DimTolValue
Set DimTolValue = Dimension1
Dim oTolType
Dim oDisplayMode
Dim oTolName
Dim oUpTolS
Dim oLowTolS
Dim oUpTolD
Dim oLowTolD
DimTolValue.GetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode
oTolName = "TOL_NUM2"
DimTolValue.SetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode
DimTolValue.GetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode
oUpTolD = 0.2
oLowTolD = 0.0
DimTolValue.SetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode

'---------------------------------------------------------------------------------------------------

Dim DimDimValue
Set DimDimValue = Dimension1.GetValue

DimDimValue.SetFormatName 1, "NUM.DIMM"
DimDimValue.SetFormatPrecision 1, "0.100" 'precision

'---------------------------------------------------------------------------------------------------
Dim oNoOff
oNoOff=InputBox ( "Enter No Off Holes" )

Select Case Value

Case 0

Dim oNoOffText
oNoOffText = oNoOff & "x "

Dim oBefore
oBefore =oNoOffText
Dim oAfter
'oAfter = "oAfter"
Dim oUpper
'oUpper = "Upper"
Dim oLower
'oLower = "Lower"

Dimension1.GetValue.SetBaultText 1, oBefore, oAfter, oUpper, oLower

Case >0

Dim oBefore
oBefore = "oBefore"
Dim oAfter
oAfter = "oAfter"
'Dim oUpper
'oUpper = "Upper"
'Dim oLower
'oLower = "Lower"

Dimension1.GetValue.SetBaultText 1, oBefore, oAfter, oUpper, oLower


End Select

'----------------------------------------------------------------------------



Dim myDim 'As DrawingDimension
Set myDim = CATIA.ActiveDocument.Selection.Item(1).Value
Dim myDimLine 'As DrawingDimLine
Set myDimLine = myDim.GetDimLine
myDimLine.DimLineGraphRep = catDimLine2Parts

MyDim.RestoreValuePosition()


End Sub
'-------------------------------------------------------------------------------------

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources