iLogic Rename detail view without renaming in tree

iLogic Rename detail view without renaming in tree

Anonymous
Not applicable
655 Views
6 Replies
Message 1 of 7

iLogic Rename detail view without renaming in tree

Anonymous
Not applicable

Hello all,

I´m trying to write a code which will rename detail in drawing, but not in tree. 

So option: 

oView.Name = .....

isn´t right way. 

I´m able to rename detail above detail  name via:  

     oView.ShowLabel = True
     oStringItem =  .....
     oStringScale = "<Br/><StyleOverride FontSize='0,4'> (<DrawingViewScale/>)  </StyleOverride>"
				
				
     oView.Label.FormattedText = oStringItem & oStringScale

 But the name on "text leader" is still the same like on tree. I tried:

Dim oItemValue As String
oItemValue = "the same like in oStringItem"

 Is possible to change name of detail without changing name in tree? I need this, because I´m controling views (supress, unsupress) via detail name from tree. 

Thanks a lot. 

0 Likes
656 Views
6 Replies
Replies (6)
Message 2 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Hoping that adding general note would be helpful in this situation.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 7

marcin_otręba
Advisor
Advisor
Dim osh As Sheet = ThisDoc.Document.activesheet
Dim oSketch As Sketch
Dim oview As DrawingView
For Each osh In ThisDoc.Document.sheets
For Each oview In osh.DrawingViews
	oview.ShowLabel=True
oview.Label.FormattedText="111"
	Next
Next

 

then

 

Dim osh As Sheet = ThisDoc.Document.activesheet
Dim oSketch As Sketch
Dim oview As DrawingView
For Each osh In ThisDoc.Document.sheets
For Each oview In osh.DrawingViews
if oview.Label.FormattedText="111" then
'do something
end if
	Next
Next

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 4 of 7

DRoam
Mentor
Mentor

After some digging, I found that unfortunately, the defining "fence" or boundary for the Detail View is not exposed in any way to the API, so you cannot do anything with it (move it, resize it, OR edit its label text) via the API/iLogic.

 

You might create a request for this in the Ideas section, it's definitely a reasonable request.

 

In the meantime... the only alternative I can think of is if it would be possible for you to specify whether the detail view should be suppressed using Attributes rather than the Name of the view. Every view (in fact, most objects in Inventor) have "Attribute Sets", to which you can add your own custom Attribute Sets, and then add Attributes to those. Attributes are very similar to iProperties, in that they can have text, number, boolean, and date values.

 

Rather than your users (or you) setting the name of a Detail View to some value with information about when it should be suppressed, you could instead write that information to an Attribute of the view. This wouldn't be visible anywhere in the UI, but you could write iLogic scripts to prompt the user for the information, and then the iLogic could read that whenever it needs to know whether or not to suppress the view.

 

Not sure if that's a viable option for you, but it's the best thing I can think of.

0 Likes
Message 5 of 7

Anonymous
Not applicable

Hello,

Yes this way will be good. I didn´t find how to write new information to an Attribute of the view.

Can you help me please?

 

 

0 Likes
Message 6 of 7

DRoam
Mentor
Mentor

Hi @Anonymous, below is a rule that demonstrates how to provide information in a string attribute value for a view, then retrieve that info to determine if the view should be suppressed. You would do this rather than providing the information in the View Name. Then you can freely change the View Name to how you want it to appear in the detail fence/boundary and the View Label.

 

Sub Main()
	' NOTE: Before running rule, change "AttributeSetName" to your desired name in "GetViewInfoAttribute" Sub.
	
	' The code below demonstrates how a user can provide the "view info" for a View.
	Dim view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select view to provide info for...")
	
	If view Is Nothing Then Exit Sub
		
	Dim currentInfo As String = RetrieveViewInfo(view)
	
	Dim info As String = InputBox("Provide view info (this is what you would normally put as the View Name):", "View Info", currentInfo)
	
	SupplyViewInfo(view, info)
	MessageBox.Show("Info changed to '" & info & "'","View Info",MessageBoxButtons.OK, MessageBoxIcon.Information)
	
	' The code below demonstrates how you would retrieve info from the view, probably in another rule:
	Dim retrievedInfo As String = RetrieveViewInfo(view)
	
	If retrievedInfo.Contains("YourKeyword") Then
		view.Suppressed = True
		MessageBox.Show("View suppressed.","View Info",MessageBoxButtons.OK, MessageBoxIcon.Information)
	Else
		view.Suppressed = False
		MessageBox.Show("View un-suppressed.","View Info",MessageBoxButtons.OK, MessageBoxIcon.Information)
	End If
End Sub

Sub SupplyViewInfo(view As DrawingView, info As String)
	GetViewInfoAttribute(view).Value = info
End Sub

Function RetrieveViewInfo(view As DrawingView) As String
	Return GetViewInfoAttribute(view).Value
End Function

Function GetViewInfoAttribute(view As DrawingView) As Inventor.Attribute
	Dim AttributeSetName As String = "YourCustomAttributeSetName"
	Dim AttributeName As String = "ViewInfo"

	Dim attSet As AttributeSet
	If view.AttributeSets.NameIsUsed(AttributeSetName) Then
		attSet = view.AttributeSets.Item(AttributeSetName)
	Else
		attSet = view.AttributeSets.Add(AttributeSetName)
	End If

	Dim att As Inventor.Attribute
	If attSet.NameIsUsed(AttributeName) Then
		att = attSet.Item(AttributeName)
	Else
		att = attSet.Add(AttributeName, ValueTypeEnum.kStringType, "")
	End If
	
	Return att
End Function
0 Likes
Message 7 of 7

Anonymous
Not applicable

Hello, 

thank you so much. 

I´ll look at it on monday. 

 

0 Likes