Is it possible to get and edit a weakly-typed object

Is it possible to get and edit a weakly-typed object

Andrii_Humeniuk
Advisor Advisor
483 Views
5 Replies
Message 1 of 6

Is it possible to get and edit a weakly-typed object

Andrii_Humeniuk
Advisor
Advisor

Hello everybody.
I want to get and edit the section label text on the drawings, but I can't find it in the API. All I know is that the object is "kGenericObject" (2130706445).

Вefore:

Снимок экрана 2023-04-27 151110.png

After:

Снимок экрана 2023-04-27 151049.png

Any help would be appreciated.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
484 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @Andrii_Humeniuk.  Those are a bit odd to work with by code.  But here is a fairly simple iLogic code that you can use to change that text the easy way.  I left a few extra lines in there, but quoted out, just for interest.

Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews
For Each oView As DrawingView In oViews
	If oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType Then
		Dim oSView As SectionDrawingView = oView
		oSView.Name = oSView.Name & " (2)"
'		oSView.Label.FormattedText
'		Dim oSectSketch As DrawingSketch = oSView.SectionLineSketch
'		Dim oPView As DrawingView = oSView.ParentView 'may be Nothing
	End If
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

Andrii_Humeniuk
Advisor
Advisor

Hi @WCrihfield . Thank you for your reply. But this is somewhat not what I want. I will try to explain in more detail.
I have a section view and section mark on different sheets. But I need to add in the name of the type of section on which sheet it is located (I have already done this). And add in the designation of the section on which sheet the type of section is located.

Снимок экрана 2023-04-28 075956.pngСнимок экрана 2023-04-28 080047.png

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 4 of 6

Andrii_Humeniuk
Advisor
Advisor

Hello everyone.
I'm still struggling to solve this problem, but I think I've found what I need. It turns out that among the CommandNames there are some that, according to their description, look like editing text on a section mark.

DrawingViewEditTextOnDetialSectionAnnoCtxCmd Edit Text
DrawingViewEditTextOnFirstSectionAnnoCtxCmd Edit Text
DrawingViewEditTextOnSecondSectionAnnoCmd Edit Text

Unfortunately, in my case the commands don't work, maybe someone has an idea why?

Example of my code:

Dim oInvApp As Inventor.Application = ThisApplication
Dim oCM As CommandManager = oInvApp.CommandManager
Dim oDDoc As DrawingDocument = oInvApp.ActiveDocument
Dim oSS As SelectSet = oDDoc.SelectSet
For Each oView As DrawingView In oDDoc.ActiveSheet.DrawingViews
	If oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType Then
		oSS.Select(oView)
		oCM.ControlDefinitions.Item("DrawingViewEditTextOnSecondSectionAnnoCmd").Execute()
		oSS.Clear()
	End If
Next

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 5 of 6

jnowel
Advocate
Advocate

I tried the Control Definition above, but it only works when you select the specific Section Line Text/Label (not the Section Drawing View/ View.Label object)
I'm not sure how to access that "Text/Label" as it seems not available in the API.

A different approach that may achieve your desired outcome is to put a SketchedSymbol (with a Prompted Text) as a placeholder for the Sheet number where the Section View is located.
That SketchedSymbol need to be manually attached (via leader) though on the section line as I don't see a way to attach it via API 

Message 6 of 6

g.georgiades
Advocate
Advocate

You can try this guy to convert the kGerenic to a usable object or get the view that objecet is a child of.

 

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=DrawingDocument_ProcessViewSelection

 

I use this to get the filename from a part in any view when part select mode is active..

 

Dim sel As SelectSet = doc.SelectSet
If sel.Count < 1 Then Exit Sub

dim vw as DrawingView = nothing
dim obj as object = nothing 'unknown type for now
oDoc.ProcessViewSelection(sel.Item(1), vw, obj)

If obj IsNot Nothing Then
	If TypeOf obj Is ComponentOccurrence AndAlso Not CType(obj, ComponentOccurrence).Suppressed Then
		path.Add(CType(obj, ComponentOccurrence).Definition.Document.FullFileName)
	ElseIf TypeOf obj Is Document Then
		path.Add(CType(obj, Document).FullFileName)
	End If
End If

 

It will spit out the drawing view that the object is a child of and it will spit out the object itself as a usable variable, you just have to cast it or make a new variable with a strong type. The view label is probably a text object, or you can just use the DrawingView output directly to access the label.