[b] 'UNDO' function from within VBscript or VBA[/b]
[b] 'UNDO' function from within VBscript or VBA[/b]
(OP)
I'm very new at Catia VB programming and have written a program to create normal lines to through points of an open body and normal to a face. When the first line is created the user is prompt to reverse direction YES/NO. If yes, I want to 'UNDO' the created first line, change the length variable and then create the first and subsequent lines in the opposite direction. I've got it all except the 'UNDO' for the first line.
This is the loop:
For i = 1 to countA
Set reference2 = Part1.CreateReferenceFromObject(hybridShapes1.Item(i))
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, Length, 0, False)
hybridBody2.AppendHybridShape hybridShapeLineNormal
If ( i = 1 ) then
part1.Update
response = msgbox ("Do you want to Flip?",4)
If (response = 6) then
Length=-25.4
>>>undo goes here<<<
msgbox "reversed direction"
i=0
End if
End if
next
This is the loop:
For i = 1 to countA
Set reference2 = Part1.CreateReferenceFromObject(hybridShapes1.Item(i))
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(reference1, reference2, Length, 0, False)
hybridBody2.AppendHybridShape hybridShapeLineNormal
If ( i = 1 ) then
part1.Update
response = msgbox ("Do you want to Flip?",4)
If (response = 6) then
Length=-25.4
>>>undo goes here<<<
msgbox "reversed direction"
i=0
End if
End if
next





RE: [b] 'UNDO' function from within VBscript or VBA[/b]
CATIA.StartCommand ("Undo")
RE: [b] 'UNDO' function from within VBscript or VBA[/b]
Since the request, I '.add' the line to a selection and delete it. Works fine.
I still would like to know if there is a way to 'UNDO' only the last created element.
RE: [b] 'UNDO' function from within VBscript or VBA[/b]
If you've got a reference to the last created object (hybridShapeLineNormal1) , add it to a selection and then delete the object using the selection.