iLogic Hiding Part Sketches in a drawing

iLogic Hiding Part Sketches in a drawing

They_Call_Me_Jake
Advocate Advocate
1,195 Views
3 Replies
Message 1 of 4

iLogic Hiding Part Sketches in a drawing

They_Call_Me_Jake
Advocate
Advocate

Hello All,

 

Need some help from the Inventor community. I have a drawing with a part in a drawing view (not a part in an assembly) that I need to hide a few different sketches. I have code for hiding sketches in a part that is in an assembly in a drawing view but being that I am extremely new to programming I cannot for the life of me figure out how to adjust it for a part only scenario. I have searched to interwebs to see if anyone else has posted about this but everything that I have found involves working with sketches in a part in an assembly in a drawing view. Could someone please help me with this. I'm sure it's an easy thing to do for someone who knows programming. Here is the code that I have been using for my part in assembly in drawing view sketch hiding. TIA

 

 

Dim oDoc As DrawingDocument
	oDoc = ThisApplication.ActiveDocument

Dim oActiveSheet As Sheet
	oActiveSheet = oDoc.ActiveSheet

Dim oDrawingView As DrawingView
	oDrawingView = oActiveSheet.DrawingViews(1)
    
Dim oRefDoc As AssemblyDocument
	oRefDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
	
Dim oAssDef As AssemblyComponentDefinition
	oAssDef = oRefDoc.ComponentDefinition
    
Dim oOcc As ComponentOccurrence
	oOcc = oAssDef.Occurrences(1)
    
Dim oPart As PartDocument
	oPart = oOcc.Definition.Document

Dim oDef As PartComponentDefinition
	oDef = oPart.ComponentDefinition

Dim oSketch As PlanarSketch
	For Each oSketch In oDef.Sketches
		Dim oSketchProxy As PlanarSketchProxy
		oOcc.CreateGeometryProxy(oSketch, oSketchProxy)
			If oSketch.Name = BackHoleSketch Then
				oDrawingView.SetVisibility(oSketchProxy, False)
			End If
			
			If oSketch.Name = BackHoleSketch1 Then
				oDrawingView.SetVisibility(oSketchProxy, True)
			End If
	Next

 

0 Likes
1,196 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Hi,

 

If my understanding is right then your requirement is to hide the sketches with particular name in part document on that case the following code might help you.

 

SyntaxEditor Code Snippet

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oType As DocumentTypeEnum
Dim oSketch As Sketch
oType = oDoc.DocumentType
If oType = kPartDocumentObject Then
   For Each oSketch In oDoc.ComponentDefinition.Sketches
        If oSketch.Name = "Sketch2" Then
            oSketch.Visible = False
        ElseIf oSketch.Name = "Sketch1" Then
            oSketch.Visible = False
        End If
   Next
Else 
MessageBox.Show("Not a part document", "Title")
End If
0 Likes
Message 3 of 4

They_Call_Me_Jake
Advocate
Advocate

@Anonymous.kasilinga Thanks for the quick response. In answer to your question....Actually no. I've seen the code you posted in another forum topic and tried to use it but it will not work because I am not working in the part document directly, I am actually working in a drawing document .(idw) and I have inserted a base view of a part (not an assembly). I need to be able to hide a couple of the sketches in that part model but I need to do it in the drawing.

I attached a picture which shows one of the sketches I want to hide highlighted in blue in the design tree.

 

 

Capture.JPG

0 Likes
Message 4 of 4

Anonymous
Not applicable

Greetings,

Attached is an example of what you want... maybe.

 

I figured out how to hide any sketch that I want within a part.  So there is a drawing file attached and a part file.  Each have iLogic rules that will allow you to hide the individual sketch.  You can play with it and see if its what you are looking for.

 

The main limitation on this is that you need to know the drawing view.  For me that works because it will always be the same numbered view.

 

 

Dim oDoc As DrawingDocument
 oDoc = ThisApplication.ActiveDocument
    
Dim oView As DrawingView
 oView = oDoc.ActiveSheet.DrawingViews.Item(1)

Dim orefdoc As PartDocument
 orefdoc = ThisApplication.Documents.Open("K:\Inventor\Coils\LETDATA.ipt", False)

Dim oevap1 As PlanarSketch

 oevap1 = orefdoc.ComponentDefinition.Sketches.Item(2)


Select Case NumofLET
	Case 1.0
	 oView.SetVisibility(oevap1, True)
0 Likes