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!

Hide/Unhide specific Geo Set macro 1

Status
Not open for further replies.

MKEdits

Mechanical
Jan 9, 2023
31
0
0
PL
Hello, I work on a bit large macro which also should unhide particular Geometrical Set which was hidden by designers in every assembly. How should I define visproperties to get proper result?

Code:
Set part1 = partDoc1.Part
				
				Set bodies1 = part1.Bodies
				
				Set body1 = bodies1.Item("Gewinde")
				
				part1.InWorkObject = body1
				
				Set shapeFactory1 = part1.ShapeFactory
				
				Set body2 = bodies1.Item("Schlichtbearbeitung")
				
				Set shapes1 = body2.Shapes
						
				Set hybridBodies3 = part1.HybridBodies
								
				Set hybridBody3 = hybridBodies3.Item("Output")
								
				Set hybridShapeFactory3 = part1.HybridShapeFactory
				
				Set bodies3 = part1.Bodies
				
				Set body3 = bodies3.Item("PartBody")
				
				Set shapes3 = body3.Shapes
				
				Set assemble3 = shapes3.Item("Bohrbearbeitung")
				
				Set reference3 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(Pad.3;2);None:();Cf12:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR29)", assemble3)
				
				Set reference4 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(Pocket.4;2);None:();Cf12:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR29)", assemble3)
				
				Set hybridShapePlaneOffset3 = hybridShapeFactory3.AddNewPlaneOffset(reference3, 0.000000, True)
				
				Set hybridShapePlaneOffset4 = hybridShapeFactory3.AddNewPlaneOffset(reference4, 0.000000, True)
				
				hybridBody3.AppendHybridShape hybridShapePlaneOffset3
				
				hybridBody3.AppendHybridShape hybridShapePlaneOffset4
				
				hybridShapePlaneOffset3.Name = "LIMIT_PLANE"
				
				hybridShapePlaneOffset4.Name = "SKIZZE_PLANE"
				
				part1.InWorkObject = hybridShapePlaneOffset3
				part1.Update
				
				part1.InWorkObject = hybridShapePlaneOffset4
				part1. Update

				Dim selection3 
				Set selection3 = partDoc1.Selection
				Call MsgBox ("Etap 3: Otwory", vbInformation, Title3)
								
				selection4.clear
				Set selection5 = partDoc1
				
				'status1= selection3.SelectElement2(InputObjectType1, "Wybierz SKIZZE_PLANE", False) 'choosing drilled plane
				
				Set bodies5 = part1.Bodies
				
				Set body5 = bodies5.Item("PartBody")
				
				Set shapes5 = body5.Shapes
				
				bodies5.VisProperties.Parent.SetShow 0

Regards,
M
 
Replies continue below

Recommended for you

visproperties belongs to selection. so you need to add your geometrical set to your selection and work on that.

regards,
LWolf
 
LWolf probably my GeoSet is already in selection, because after my selection there are created 2 planes in GeoSet "Output" which is hidden and i want to unhide it. Does creating planes in it means its selected or do I need to select exact GeoSet to set visprops?


Regards,
M
 
LWolf, is there way to automatize it a bit that i dont have to select exact GeoSet but only Product/Part?

Code:
[COLOR=#729FCF]Set[/color] SH1 = productDocument3.Selection

[COLOR=#729FCF]Dim[/color] InputObjectType5([COLOR=#EF2929]0[/color])
InputObjectType5([COLOR=#EF2929]0[/color]) = [COLOR=#D3D7CF]"GeometricElements"[/color]	

status3= SH1.SelectElement2(InputObjectType5, [COLOR=#D3D7CF]"Wybierz Output"[/color], [COLOR=#EF2929]False[/color]) [COLOR=#73D216]'define plate which include "Output" in it[/color]
  [COLOR=#729FCF]If[/color] status3 = [COLOR=#D3D7CF]"Normal"[/color] 
    [COLOR=#73D216]'Set partDoc2 = SH1.Item(1).Value.ReferenceProduct.Parent.Part.hybridBodies.Item("Output")[/color]
    SH1.Visproperties.SetShow [COLOR=#EF2929]0[/color]
  [COLOR=#729FCF]ElseIf[/color] status3 = [COLOR=#D3D7CF]"Cancel"[/color][COLOR=#729FCF] Then[/color]
    MsgBox strNoPlate1 , vbCritical, Title2
[COLOR=#729FCF]Exit Sub[/color]

Regards,
M
 
if you know the name of your geoset (seems to be "Output") then you can add that to your selection
Code:
SH1.add xxx
or you can search for it in each and every part of your selection (could be an assembly or several parts)
Code:
SH1.search xxx

regards,
LWolf
 
more or less like this:
Code:
Option Explicit
Sub catmain()
    Dim mySel
    Set mySel = CATIA.ActiveDocument.Selection
    mySel.clear
    Dim EnableSelectionFor(0)
    EnableSelectionFor(0) = "Product"
    Dim status3
    status3 = mySel.SelectElement2(EnableSelectionFor, "Wybierz Output", False)
    Dim SelString As String
    SelString = "(Name=Output & 'Generative Shape Design'.'Geometrical Set'),sel"
    
    mySel.Search SelString
    If mySel.Count > 0 Then
        mySel.VisProperties.SetShow 0
    End If
End Sub
I am assuming your GeoSet name is "Output"
you can select either a part or a complete assembly

regards,
LWolf
 
you can copy the ordinary CATIA search string (Ctrl + F) which is available once you perform a CATIA search, and attempt to add the performed search string to favorites...
that is how I ended up with my SelString contents...

regards,
LWolf
 
Status
Not open for further replies.
Back
Top