Hi @Reinier,
Here is an ilogic rule per johnsonshiue's suggestion.
This rule will:
- run through the assembly occurrences
- and if they are a part it adds them to a list for you to select from
- then it looks in that part and finds all of the sketches
- and adds them to a list for you to select from
- once you've selected the part and the sketch within it to work with, it goes back through the assembly
- and turns on the visibility of the sketch in each instance
Notes:
- due to time constraints, this rule is not written in a very streamlined way, and has not been tested much at all.
- this rule is not looking at the pattern, so if the selected part file is used in the pattern, and also is used elsewhere in the assembly, the sketch will be turned on in all instances
This is just a "quick and dirty" version of this rule. If you have questions about it, or would like further refinements of it, I would suggest you create a new post on the Inventor Customization forum with a reference link back to this topic:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
create a new ilogic rule in your drawing and paste this in:
'start of ilogic code
Dim oDoc As DrawingDocument: oDoc = ThisDoc.Document
oModel = ThisDoc.ModelDocument
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
oSheets = oDoc.Sheets
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
MsgBox("Select a drawing view before running the ilogic rule")
Exit Sub
End If
'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = trycast(osset.item(1), DrawingView)
Dim oAssy As AssemblyDocument
If oView IsNot Nothing Then
oAssy = oView.ReferencedDocumentDescriptor.ReferencedDocument
Else
Exit Sub
End If
If oAssy.DocumentType <> kAssemblyDocumentObject Then
MsgBox("The selected view does not reference an assembly file.")
Exit Sub
End If
Dim PartList As New ArrayList
Dim SketchList As New ArrayList
Dim oSubOcc As ComponentOccurrence
'get the part to use
For Each oSubOcc In oAssy.ComponentDefinition.Occurrences
'split occurence name at colon
oSplit = Split(oSubOcc.Name,":")
'check that list doesn't already contain name
If PartList.Contains(oSplit(0)) = False Then
'add name
PartList.add(oSplit(0))
End If
Next
'get user input
sPart = InputListBox("Select a part", PartList, "", "iLogic", "Avalaible parts")
If sPart = "" Then
MsgBox("Nothing selected.")
Exit Sub
End If
'get the sketch to use
For Each oSubOcc In oAssy.ComponentDefinition.Occurrences
'split occurence name at colon
oSplit = Split(oSubOcc.Name,":")
If oSplit(0) = sPart Then
Dim oSubPartDef As PartComponentDefinition
oSubPartDef = oSubOcc.Definition
Dim oSketch As PlanarSketch
For Each oSketch In oSubPartDef.Sketches
If SketchList.Contains(oSketch.Name) = False Then
SketchList.add(oSketch.Name)
End If
Next
End If
Next
'get user input
sSketchName = InputListBox("Select a sketch", SketchList, "", "iLogic", "Avalaible Sketches")
If sSketchName = "" Then
MsgBox("Nothing selected.")
Exit Sub
End If
'turn the sketches on
Dim oSketchToUse As PlanarSketch
For Each oSubOcc In oAssy.ComponentDefinition.Occurrences
If oSubOcc.DefinitionDocumentType =
kPartDocumentObject Then
'split occurence name at colon
oSplit = Split(oSubOcc.Name,":")
If oSplit(0) = sPart Then
Dim oSubPartDef As PartComponentDefinition
oSubPartDef = oSubOcc.Definition
For Each oSketchToUse In oSubPartDef.Sketches
If sSketchName = oSketchToUse.Name Then
Exit For
End If
Next
End If
End If
Try
'create sketch proxy in the drawing
Dim oSketchProxy As PlanarSketchProxy
Call oSubOcc.CreateGeometryProxy(oSketchToUse,
oSketchProxy)
'Set Visibility of the Proxy Object
Call oView.SetVisibility(oSketchProxy, True)
Catch
MsgBox("Error. View might not be normal to sketch.")
End Try
Next
