Community
Hello,
I'm trying to get drawing dimensions for just one feature but it's not working.
Sub Main()
Dim refDoc As Document
Dim oFeatureName As String = "f1"
Dim oFeatureDimensions As FeatureDimensions
Dim oSheet As Sheet = ThisApplication.ActiveDocument.ActiveSheet
For Each oView As DrawingView In oSheet.DrawingViews
refDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
oFeatureDimensions = GetFeatDims(refDoc,oFeatureName)
If Not oFeatureDimensions Is Nothing Then oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView,oFeatureDimensions)
Next
End Sub
Function GetFeatDims(ByVal oDoc As Document,ByVal oName As String) As FeatureDimensions
Dim pDoc As PartDocument
If Not oDoc.DocumentType = kPartDocumentObject Then Return Nothing Else pDoc = oDoc
For Each pFeature As PartFeature In pDoc.ComponentDefinition.Features
If pFeature.Name = oName Then Return pFeature.FeatureDimensions
Next
Return Nothing
End Function
Any ideas why?
Solved! Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
Hi @atomic.lex . You need to create a collection of dimensions using the GetRetrievableDimensions() function. Please see my changes to your code:
Public Sub Main()
Dim refDoc As Document
Dim oFeatureName As String = "f1"
Dim oFeat As PartFeature
Dim oSheet As Sheet = ThisApplication.ActiveDocument.ActiveSheet
Dim oGDems As GeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions
For Each oView As DrawingView In oSheet.DrawingViews
refDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
oFeat = GetFeatDims(refDoc,oFeatureName)
If oFeat Is Nothing Then Continue For
Dim oObjDems As ObjectCollection = oGDems.GetRetrievableDimensions(oView, oFeat)
Call oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView, oObjDems)
Next
End Sub
Function GetFeatDims(ByVal oDoc As Document, ByVal oName As String) As PartFeature
Dim pDoc As PartDocument
If Not oDoc.DocumentType = kPartDocumentObject Then Return Nothing Else pDoc = oDoc
For Each pFeature As PartFeature In pDoc.ComponentDefinition.Features
If pFeature.Name = oName Then Return pFeature
Next
Return Nothing
End Function
Andrii Humeniuk - Leading design engineer
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Can't find what you're looking for? Ask the community or share your knowledge.