Find Sketch containing a specified dimension parameter

Find Sketch containing a specified dimension parameter

FxRod
Enthusiast Enthusiast
199 Views
1 Reply
Message 1 of 2

Find Sketch containing a specified dimension parameter

FxRod
Enthusiast
Enthusiast

Hi! This is a "share your knowledge"-post. I make intense use of sketchbased top-down-modeling. While this, I sometimes need to find where in a bunch of sketches a certain dimension parameter of which I know the name is defined. So I wrote some lines of code for this. Or did I miss some out-of-the-box function that does the same?

 

Dim name As String = InputBox("Enter the the name of the dimension to find:", "Find sketch containing dimension")
If (name <> "") Then
	Dim oDoc As PartDocument = ThisDoc.Document
	Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition

	Dim oSketches As PlanarSketches = oCompDef.Sketches
	Dim waehl As SelectSet = oDoc.SelectSet

	waehl.Clear

	For Each oSketch As Sketch In oSketches
		For Each oDimConst As DimensionConstraint In oSketch.DimensionConstraints
			If (oDimConst.Parameter.Name = name) Then
				Logger.Info(oDimConst.Parameter.Name)
				waehl.Select(oSketch)
			End If
		Next
	Next
End If
0 Likes
200 Views
1 Reply
Reply (1)
Message 2 of 2

Houston_Shimala
Contributor
Contributor

I wrote a function with basically the same idea just alittle different a few years back, but this is exactly how I did it. I don't think there is a faster or out-of-box way of doing this.

0 Likes