Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem to use Selection.Add( ) command in VB script

Status
Not open for further replies.

Eland

Aerospace
Jul 21, 2004
5
I'm trying to select some elements to hide, that is the same thing to click mouse with Ctrl key in the working window. However I cannot go further because of the Selection.Add() command.
Maybe the problem is improper object in the ().

My sample script is shown bellow


Language="VBSCRIPT"

Sub CATMain()

Set part1 = CATIA.ActiveDocument.Part
Set selection1 = CATIA.ActiveDocument.Selection

Set hybridBodies1 = part1.HybridBodies

Number1 = hybridBodies1.Count - 1
For j = 1 To Number1
Set hybridBody1 = hybridBodies1.Item(j)
Set hybridShapes1 = hybridBody1.HybridShapes
Number2 = hybridShapes1.Count
For i = 1 To Number2
Set elementToHide = hybridShapes1.Item(i)
Set selection = selection1.Add(elementToHide) <<<<< This guy has an error.
Next
Next
CATIA.StartCommand("Hide/Show")

End Sub


Oh, one more thing... Is is possible to select open_body itself to hide all elements belonged to that?

Thank you in precedence.
 
Replies continue below

Recommended for you

Hi,

Set selection = selection1.Add(elementToHide) <<<<< This guy has an error

should be just...

selection1.Add elementToHide

 
Oh, I see. Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor