Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

how to hide element without selection

Status
Not open for further replies.

Catiaer

Mechanical
Nov 9, 2019
13
0
0
KR
Hello,
I'm making a simple script that creates a geometrical set and hide it in selected parts.
The problem is, when I use both "SelectElement3" methode and "VisProperties" methode,
I have to add geo set and clear selection it.
Then I would like to know, whether there is a way to hide a geo set without selection.
Code:
Dim selection1 'As Selection
Set selection1 = CATIA.ActiveDocument.Selection

Dim Inputobject(0)
Inputobject(0) = "Part"

selection1.Clear
MsgBox "Please, select parts", vbInformation, "CATIA V5"
Status1 = selection1.SelectElement3(Inputobject, "select parts", True, CATMultiSelTriggWhenUserValidatesSelection, False)
    If (Status1 = "Cancel") Or (Status1 = "Undo") Then Exit Sub

For n = 1 To selection1.Count
    Dim documents1 As Documents
    Set documents1 = CATIA.Documents
    
    Dim SelObjName1 As String
    SelObjName1 = selection1.Item(n).Value.Parent.Name
    
    Dim partDocument1 As PartDocument
    Set partDocument1 = documents1.Item(SelObjName1)
    
    Dim part1 As Part
    Set part1 = partDocument1.Part
    
    Dim hybridBodies1 As HybridBodies
    Set hybridBodies1 = part1.HybridBodies
    
    Dim hybridBody1 As HybridBody
    Set hybridBody1 = hybridBodies1.Add()
    
    part1.Update

    Dim visPropertySet1 As VisPropertySet
    Set visPropertySet1 = selection1.VisProperties
    
    selection1.Add hybridBody1
    visPropertySet1.SetShow 1
    selection1.Clear
Next
 
Replies continue below

Recommended for you

You can refine the search however you need, but this is what I use to search an entire product structure for all geosets. You can see this by recording a macro and using the Edit >> Search function.

Code:
selection1.Search "(((CATStFreeStyleSearch.OpenBodyFeature + CATPrtSearch.OpenBodyFeature) + CATGmoSearch.OpenBodyFeature) + CATSpdSearch.OpenBodyFeature),all"
Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetShow 1
 
Hi, Lucas
Thank you for your answer.
I had similarly thought your code also before.
I tried to change a name of geo set and search it in all parts.
This is my last solution ;-)
Just, I would like to know another way to hide without selection.
I have already searched about ".VisProperties" in VB Help document.
But there was nothing what I want.
Because the ".VisProperties" methode needs a selection.
 
I see, I thought you wanted to remove user interactive "selection". I don't know of any other way to hide except adding to a selection/visproperties.

Why are you trying to avoid this? what is the issue?
 
Thank you for your interesting.
Because I had already made a macro for a stock size all of products.
But it is very slow, when I have so many parts.
Normally my project has more than 500 parts, sometimes 1000 parts.
Actually I don't need to make in all parts.
That reason why I tried to make with "SelectElement3".
 
My suggestion is that you make two separate for loops.
In the first loop, go through all the selection values, create the geometrical set and store the parts in an array.
In the second loop, go through all the parts in the array and hide the geometrical set.
 
@Manuel Pimenta
Thank you for your reply, but I couldn't find a solution from your suggestion.
Otherwise I used open new window function, then it works for me well.

@Little Cthulhu
Thank you for your reply, I tried to use your suggestion in my code, but I got an error.
I add on error resume next and I compared each other, but it seems to be similar..
I googled about this error, but I couldn't find anything.
Error code is -2147417851 (80010105) Automation error. The server threw an exception.
Do you have an experience about this and any solutions?
 
Status
Not open for further replies.
Back
Top