Can I use ilogic to turn off visibility of all named Entities?

Can I use ilogic to turn off visibility of all named Entities?

skseo
Contributor Contributor
340 Views
2 Replies
Message 1 of 3

Can I use ilogic to turn off visibility of all named Entities?

skseo
Contributor
Contributor

Can I use ilogic to turn off visibility of all named Entities?

 

skseo_0-1675757896641.png

 

0 Likes
Accepted solutions (2)
341 Views
2 Replies
Replies (2)
Message 2 of 3

pmartick
Advocate
Advocate
Accepted solution

After seeing no one else has seemingly answered this question anywhere else I needed to find out this answer for myself and to help others who've asked this question.

 

Autodesk, it would be great to have a Visibility function added to the NamedEntities iLogic interface somewhere so we don't have to utilize these workarounds.

 

When named entities are inside a part there are two attribute sets added to the part document and each one contains one attribute inside:

  • iLogicEntityNameSet
    • iLogicEntityNamesOrdered
  • iLogicEntityNameSetTransient
    • iLogicEntityNamesVisible

Each of those attributes is a string value that lists the names of the entities delimited by Tab (you can use Chr(9) to insert a tab into your string):

  • iLogicEntityNamesOrdered = "Face0        Edge0        Vertex0"
  • iLogicEntityNamesVisible = "Face0        Edge0        Vertex0"

Therefore you can get that value and change it or build a new string value and apply it to those attributes values to either change the order they're listed or change which ones are visible or not.

 

For example, if you apply a blank string to iLogicEntityNamesVisible then all named entities will be invisible.

 

After applying the changes to any of those strings you need to trigger a document save to make those changes happen in the model.

 

*This example code assumes the document was already previously saved with a Face, Edge, and Vertex already named the default names of Face0, Edge0, and Vertex0 respectively.

 

Dim oDoc as PartDocument = ThisDoc.Document

oDoc.AttributeSets("iLogicEntityNameSet")("iLogicEntityNamesOrdered").Value = "Face0" + Chr(9) + "Edge0" + Chr(9) + "Vertex0"

oDoc.AttributeSets("iLogicEntityNameSetTransient")("iLogicEntityNamesVisible").Value = "Face0" + Chr(9) + "Edge0"

oDoc.Save

 

 

Message 3 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@pmartick, building on what you provided, here is a rule to toggle all of the entities on/off

 

 

Dim oDoc As PartDocument = ThisDoc.Document

Dim oNames As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)

For i = 1 To oNames.Entities.Count

	EntName = oNames.Entities.Name(i)
	Dim EntValue As Object = oNames.Entities.Value(EntName)

	ObjectType = [Enum].GetName(GetType(ObjectTypeEnum), EntValue.type)
	'Logger.Info(ObjectType)

	If ObjectType.Contains("Work") Then Continue For 'skip work objects

	If i = 1 Then
		sString = EntName
	Else
		sString = sString + Chr(9) + EntName
	End If
'	Logger.Info(EntName)
'	Logger.Info(sString)
Next

oAttSet = oDoc.AttributeSets("iLogicEntityNameSetTransient")("iLogicEntityNamesVisible")
oHidden = (oAttSet.Value = "")

If oHidden = False Then
	oAttSet.Value = ""
Else
	oAttSet.Value = sString
End If

If Not oDoc.FullFileName = "" Then oDoc.Save

 

EESignature

0 Likes