loop through ImanagedDrawingDimenions

loop through ImanagedDrawingDimenions

m.den.ouden
Advocate Advocate
337 Views
3 Replies
Message 1 of 4

loop through ImanagedDrawingDimenions

m.den.ouden
Advocate
Advocate

Hello,

 

I'd like to know, how I can loop through the IManagedDrawingDimensions (interface) 

some explanation below

Dim iSheet As IManagedSheet = ThisDrawing.ActiveSheet
Dim iDrawingDims As Autodesk.iLogic.Interfaces.IManagedDrawingDimensions = iSheet.DrawingDimensions

For Each iDrawingDim As IManagedDrawingDimension In iDrawingDims
	'(I wanna do something like this which is kinda similar to the for each loop down below)
	'(the id is to get the name of the drawingDimension)
	MessageBox.Show(iDrawingDim.Name)
			
	'I know that iDrawingDims is an interface and this won't work. but how can I do it? 
	'I wanne loop through al the dimensions to get the name			
Next
		
For Each oDrawingDim As DrawingDimension In InventorApp.oDrawingDoc.ActiveSheet.DrawingDimensions
	'(similar to this)
Next

 

 

 

0 Likes
Accepted solutions (1)
338 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor

I'm unaware of a way to do this with the iLogic api. But iLogic uses the Inventor api. You can use this to get your names.

Not sure what you want to do with it but here it's.

Dim iSheet As IManagedSheet = ThisDrawing.ActiveSheet
Dim iDrawingDims As Autodesk.iLogic.Interfaces.IManagedDrawingDimensions = iSheet.DrawingDimensions


Dim sheet As Sheet = iSheet.NativeEntity
Dim dimensions = ThisDoc.Document.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName")

For Each dimension As DrawingDimension In dimensions

	Dim name As String = dimension.AttributeSets.Item("iLogicEntityNameSet").Item("iLogicEntityName").Value
	MsgBox(name & " - " & dimension.Text.Text)
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 4

m.den.ouden
Advocate
Advocate

I know the NativeEntity is the original set within the inventor API. so in this case I can just skip the use of IManaged.

But it gives me back one entity name. 

 

I created 3 dimensions . 2 are received from the 3d model with the function  below.

 

	Public Sub RetrieveModelAnnotations(oDrawingView As DrawingView)
		InventorApp.oDrawingDoc.SelectSet.Select(oDrawingView)
		InventorApp.ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute
		InventorApp.ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_ApplyCmd").Execute
		System.Windows.Forms.SendKeys.SendWait("{ESC}")
	End Sub

The other one is being created with some functions that I created using the IManaged interface. It is to much code to show and explain. But I can already read the name from that point but it is different from the one that I get from your loop, also I just get 1 instead of 3  which I would expect. why do the other dimensions don't have names? I think the Inventor API should allow us to loop through the dimensions and give them names or anything to grap a specific dimension so you can edit it.

 

or maybe an index position, what ever.

 

0 Likes
Message 4 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

Inventor API does not give names to dimensions. But it's possible to add attributes to almost every object. Including dimensions. That way you can give dimensions names. This is what the iLogic API does in the back ground. That also explains why my rule does not find all dimensions. It will only find dimensions created with the iLogic API. 

You can find more information about Attributes here:

https://modthemachine.typepad.com/my_weblog/2009/07/introduction-to-attributes.html 

You might also want to have a look at this tool:

https://ekinssolutions.com/nifty_attributes/ 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com