Geometry Labels - Inventor 2019

Geometry Labels - Inventor 2019

ChrisAtherton
Advocate Advocate
1,533 Views
9 Replies
Message 1 of 10

Geometry Labels - Inventor 2019

ChrisAtherton
Advocate
Advocate

Hi,

I'm creating some code where I automatically create an attributeset in the same manor as the 2019 functionality to labels can be shown ... this is so that additional information is added to the set.  Currently I have to manually toggle the labels on and off in my browser for them to appear.  So my question is: Is there some code to toggle these on and off so my attributes get labels create.  If not then is there set code that Autodesk are using to create the client graphic labels that I can use in my code?help1.png

Chris Atherton
IEng MIMechE BEng Hons
Design Automation Services Manager | Symetri
https://uk.linkedin.com/in/chrissoathe
1,534 Views
9 Replies
Replies (9)
Message 2 of 10

YuhanZhang
Autodesk
Autodesk

You can check the API PartDocument.ComponentDefinition.ClientGraphicsCollection to find the client graphics for the geometry label.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 10

ChrisAtherton
Advocate
Advocate

Thanks … I found that but was hoping more for some code so it works in the same way, rather than me having to workout what Autodesk have done to get certain points for their line / notes etc.

Chris Atherton
IEng MIMechE BEng Hons
Design Automation Services Manager | Symetri
https://uk.linkedin.com/in/chrissoathe
0 Likes
Message 4 of 10

YuhanZhang
Autodesk
Autodesk

Here is a sample VBA code to toggle the geometry name visibility:

 

Sub ToggleGeometryNameGraphics()
    Dim sGeometryName As String
    sGeometryName = "CONSTRAINT_5"
    
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oGraphicsColl As ClientGraphicsCollection
    Set oGraphicsColl = oDoc.ComponentDefinition.ClientGraphicsCollection
    
    Dim oClientGraphics As ClientGraphics
    Dim oNode As GraphicsNode
    For Each oClientGraphics In oGraphicsColl
        If oClientGraphics.ClientId = "NamedEntityGraphicsID" Then
            For Each oNode In oClientGraphics
                If oNode.DisplayName = sGeometryName Then
                    oNode.Visible = Not oNode.Visible
                    oDoc.Update
                End If
            Next
        End If
    Next
End Sub

Hope it helps.

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 10

Anonymous
Not applicable

Is it possible to use iLogic to change the appearance of geometry with an assigned name?

For instance: "CONSTRAINT_5" to (Autodesk Appearance Library) Bamboo

0 Likes
Message 6 of 10

YuhanZhang
Autodesk
Autodesk

Here is a sample iLogic code:

 

Sub Main()
	Dim oDoc As PartDocument
	oDoc = ThisDoc.Document 
	
	Dim oAttManager As AttributeManager
	oAttManager = oDoc.AttributeManager
	
	Dim oCol As ObjectCollection 
	oCol = oAttManager.FindObjects("*","*", "CONSTRAINT_5")
	
	If oCol.Count = 1 Then
		Dim oFace As Face
		oFace = oCol.Item(1)
		
		Dim oAssetLib As AssetLibrary
		oAssetLib = ThisApplication.AssetLibraries.Item("314DE259-5443-4621-BFBD-1730C6CC9AE9") 'Autodesk Appearance Library
		
		On Error Resume Next
		Dim oDocAppearance As Asset 
		oDocAppearance = oDoc.AppearanceAssets.Item("Bamboo")
		 
		If oDocAppearance Is Nothing Then
			 
			Dim oAppearance As Asset
			oAppearance = oAssetLib.AppearanceAssets.Item("ACADGen-082") 'Bamboo
			
			oDocAppearance= oAppearance.CopyTo(oDoc, True)
			
		End If
		
		oFace.Appearance = oDocAppearance
		
	End If
End Sub


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 7 of 10

MjDeck
Autodesk
Autodesk

@ChrisAtherton , are you using the NamedEntities iLogic API?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 8 of 10

J-Camper
Advisor
Advisor

@YuhanZhang,

I was curious about accessing the geometry labels too, so I tried the code you provided, modified to toggle all on/off and use as iLogic rule:

Sub Main
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oGraphicsColl As ClientGraphicsCollection = oDoc.ComponentDefinition.ClientGraphicsCollection
Dim oClientGraphics As ClientGraphics
Dim oNode As GraphicsNode

MessageBox.Show(oGraphicsColl.Count, "Title")
For Each oClientGraphics In oGraphicsColl
    If oClientGraphics.ClientId = "NamedEntityGraphicsID"
		oClientGraphics.Visible = True
        For Each oNode In oClientGraphics
			'MessageBox.Show(oNode.DisplayName, "Title")
			oNode.Visible = Not oNode.Visible
			oDoc.Update
        Next
		oClientGraphics.Visible = False
    End If
Next
End Sub

It is not working the way I had hoped:

1. if the label visibility starts as not visible, it can't find the named geometry [oGraphicsColl.Count=0]

2. if the label visibility starts as visible, it can toggle off but not toggle on

3. if the label visibility starts as visible and gets toggled off, it all gets toggled back on when the document is saved/updated

 

Is there a more direct way to access label visibility without relying on the client graphics?  I was able to get the names of the labels and the face/vertex/... that are named using: "iLogicVb.Automation.GetNamedEntities", but I can't get to the actual label object to toggle visibility.

 

I also tried going through the iLogic DockableWindow but quickly hit a road block because I can't find documentation on navigating the Tabs/folders in the iLogic DockableWindow:

'iLogic Browser "dockable window" information:
oInternalName = "ilogic.treeeditor"
oClientID = "{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}"
oTitle = "iLogic"

For Each oDockableWindow As Inventor.DockableWindow In ThisApplication.UserInterfaceManager.DockableWindows
	If oDockableWindow.InternalName = oInternalName 
		If oDockableWindow.Visible <> True Then oDockableWindow.Visible = True
		'Start using it
		'oDockableWindow
	End If
Next
Message 9 of 10

MjDeck
Autodesk
Autodesk

@J-Camper , you can't get to the labels through the DockableWindow.
We're planning to provide an API for label visibility. But I'm wondering: how would you use that API? When would you run a rule to turn a particular label on or off?
Or do you only want an API to turn all labels on or off at the same time?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 10 of 10

J-Camper
Advisor
Advisor

@MjDeck,

I just recently figured out how to get the named geometry to use in automating AssemblyJoints through "GetNamedEntities", which has been phenomenal, and I wanted to figure out how to access options on the labels themselves.  I don't have a particular need right now, but I saw others recently posting the question and I want to learn how for my own understanding.

0 Likes