ilogic retrieve feature dimensions

ilogic retrieve feature dimensions

atomic.lex
Enthusiast Enthusiast
388 Views
1 Reply
Message 1 of 2

ilogic retrieve feature dimensions

atomic.lex
Enthusiast
Enthusiast

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?

0 Likes
Accepted solutions (1)
389 Views
1 Reply
Reply (1)
Message 2 of 2

Andrii_Humeniuk
Advisor
Advisor
Accepted 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 - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature