×
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

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

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

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

(OP)
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.

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

Hi,

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

should be just...

selection1.Add elementToHide

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

(OP)
Oh, I see. Thank you very much.

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