Get all dimensions in a part

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to list all dimensions in a part. How to do it?
Steps I will follow are
1) Open the part.
2) Gather all features in the part (Which VB .NET object and method will get the all the features in the part as a container class)
3) For each feature get the dimensions associated with that feature
4) For each feature get the sketch associated with the feature
5) Get the dimensions in the sketch.
How to do the above steps?
I have the following code which does Step 1, 2 and 3
Sub QueryAndShowFeatureDimensions()
Try
Dim oDoc As Document
oDoc = InventorApplication.ActiveDocument
' Get the component definition. This owns the part specific info for the part.
Dim partDef As PartComponentDefinition
partDef = oDoc.ComponentDefinition
Dim partSketches As PlanarSketches
partSketches = partDef.Sketches
'For Each partFeature In oDoc.
' Set a reference to the selected feature.
Dim oFeature As PartFeature
Dim oFeatures As PartFeatures
oFeatures = partDef.Features
Dim oFeatureDim As FeatureDimension
Dim i As Long
Dim j As Long
i = 0
j = 0
' Iterate over all dimensions of the feature.
MessageBox.Show("Number of features in part is >" + oFeatures.Count.ToString + "<")
For Each oFeature In oFeatures
j = j + 1
i = 0
For Each oFeatureDim In oFeature.FeatureDimensions
i = i + 1
MessageBox.Show(" Feature " + CStr(j) + ". Dimension " + CStr(i) + ". Name >" + oFeatureDim.Parameter.Name + "< . Model Value >" + CStr(oFeatureDim.Parameter.ModelValue) + "<")
Next
' Show all the feature dimensions
oFeature.FeatureDimensions.Show()
Next
i = 0
MessageBox.Show(" Number of sketches is >" + CStr(partSketches.Count) + "<")
For Each partSkethch As Sketch In partSketches
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
MessageBox.Show(ex.StackTrace)
End Try
End Sub