Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic retrieve feature dimensions

1 REPLY 1
SOLVED
Reply
Message 1 of 2
atomic.lex
148 Views, 1 Reply

ilogic retrieve feature dimensions

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?

Labels (1)
1 REPLY 1
Message 2 of 2

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.

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report