×
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

How to create iterations that fixes errors VBA

How to create iterations that fixes errors VBA

How to create iterations that fixes errors VBA

(OP)
Hello,

I come with a new set of questions. I want to create a extrapol with a given value(ex: 50). If the extrapol creates an error the it should decrese the value with 1 until the operation has no errors.

In this moment i have a structure like this:

___________
Dim j As Integer
For j = 1 To SearchSelection.Count

Set hybridShapeSurfaceExplicit2 = SearchSelection.Item2(j).Value
Set reference2 = part1.CreateReferenceFromObject(hybridShapeSurfaceExplicit2)
Set hybridShapeBoundary2 = hybridShapeFactory1.AddNewBoundaryOfSurface(reference2)
Set hybridBody2 = hybridBodies2.Item("Complete Boundary UNTRIM")
hybridBody2.AppendHybridShape hybridShapeBoundary2
part1.InWorkObject = hybridShapeBoundary2
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridShapes2 As HybridShapes
Set hybridShapes2 = hybridBody2.HybridShapes
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters

Dim a As Integer
a = 50

Set reference7 = part1.CreateReferenceFromObject(hybridShapeBoundary2)
Dim hybridShapeExtrapol1 As HybridShapeExtrapol
Set hybridShapeExtrapol1 = hybridShapeFactory1.AddNewExtrapolLength(reference7, reference2, a)
hybridShapeExtrapol1.ContinuityType = 1
hybridShapeExtrapol1.BorderType = 1
hybridShapeExtrapol1.LimitType = 0
hybridShapeExtrapol1.SetAssemble True
hybridShapeExtrapol1.PropagationMode = 0
hybridShapeExtrapol1.ExtendEdgesMode = False
hybridShapeExtrapol1.ConstantLengthMode = False
Set hybridBody3 = hybridBodies1.Item("Untrim Extrapolated")
hybridBody3.AppendHybridShape hybridShapeExtrapol1
part1.InWorkObject = hybridShapeExtrapol1

part1.Update

On Error Resume Next
If Err.Number <> 0 Then
a = a - 1
Else
End If
Next

But i do not see a change in value even if the extrapol has an error.
Please help!



RE: How to create iterations that fixes errors VBA

You'll have to include the Update method in a loop something like this
- create the extrapol;
- append it;
- now create the loop: inside the loop do the update and if the update fails EDIT the extrapol (do not decrease the "a" as it makes no sense). I prefer a do-while loop for this kind of scenarios.
- exit the loop when err.number <>0

later edit: careful with On error resume next. You have to use the On error goto 0 clause to reset it.
Calin

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