Context for Publications Inventor Presentation Document in API

Context for Publications Inventor Presentation Document in API

Anton_Chernomazov
Contributor Contributor
1,682 Views
7 Replies
Message 1 of 8

Context for Publications Inventor Presentation Document in API

Anton_Chernomazov
Contributor
Contributor

I have some Inventor Presentation Document. I want to do some customising through Inventor API with C#. PresentationDocument object contains Publications indexator which requires some Context as Object type. Autodesk developer help does not contain info about it. What entity I can use as Context? 

1,683 Views
7 Replies
Replies (7)
Message 2 of 8

JoãoASilva
Advocate
Advocate

@Anton_Chernomazov ,

 

I know nothing about Presentation Document thru the API.

Can this API Object Model (2020) help you somehow?

João Silva

Mechanical Engineer

 

0 Likes
Message 3 of 8

Anton_Chernomazov
Contributor
Contributor

Unfortunately InventorObjectModel.pdf have no information about Publications entities.

0 Likes
Message 4 of 8

mjkoushik
Explorer
Explorer

Has anyone found the context for the publication object?

0 Likes
Message 5 of 8

Bert_Bimmel
Advocate
Advocate

Here's how i got hold of the Publications-Object that Autodesk seems to be trying to hideaway:

 

Bert_Bimmel_0-1697637611915.png

Unfortunately it requires some user interaction to select something useful in the GUI prior to capturing the Publications-Object via the Document's select set.
I'd appreciate very much, if there wasn't the urge to use such tinkering to get what you actually want!

0 Likes
Message 6 of 8

g.georgiades
Advocate
Advocate

Use the browsernode to bypass the context. You can adapt it to C# for your addin/program.

https://forums.autodesk.com/t5/inventor-programming-ilogic/context-for-publication-inventor-presenta... 

0 Likes
Message 7 of 8

Bert_Bimmel
Advocate
Advocate

Yes, using the Browser-Workaround to access objects, that Autodesk tries to render inaccessible works fine: I had that Idea before too to access the publication tweaks. Didn't see, that the parent node's native object is the same thing as the parent of my select set's item. 

That's because my original object of desire was the storyboard, and trying to find my path up through the object catalog lead me to the approach described above.

So here's my original intention that I'm still struggling with:

I want to turn things "back to normal", i.e. get rid of this obnoxious storyboard and snapshot's storyboard-associativity. So far, i figured out, that presentations, that have been created with older versions of inventor, and are opened in Inventor 2020+ are converted into Snaphots whose StoryboardAssociative flag is set to "false".

I haven't yet found a button in the GUI which breaks this associativity from newly created Presentations/Snapshots. But fortunately you can do it using the API:

Bert_Bimmel_0-1697694278189.png

So, after done so, you end up with some schizphrenic browser that shows different things, wether the Snapshot with broken associativity is activated for editing or not:

Bert_Bimmel_1-1697695080030.png

So, after breaking the chain to that $%&§!-Storyboard, i'd like to get rid of it. Turn's out, I can't, but at least i'd like to flush it's content down the toilet to prevent me or other's to accidentially try to alter the wrong explosion paths.

Inside the GUI I can mark the Browsernodes and say "delete", and after that I am where I want to be: Orphaned, empty Storyboard, and free explosion paths in my now unbound Snapshot:

Bert_Bimmel_2-1697695405614.png

->

Bert_Bimmel_3-1697695453052.png & 

Bert_Bimmel_4-1697695501563.png

-> I'm happy! 🙂

As this clicking-orgy is tedious and needs to be explained to everybody multiple times, i'd like to fully automate it.

 

Turns out, when I grab my PresentationsTweaks via their browsernode to call their "delete" method, I end up with an empty browser, but a still populated Storyboard:

Bert_Bimmel_5-1697695717891.png

 

So, how do i get rid of the storyboard's content? That's why i ended up trying to get hold of the storyboard-object by going through a horse's a55 to get to its mouth, to find somthing i can flush there, but apparently, the API is as messed up as the GUI. At least, there is nothing left, that i could flush:

Bert_Bimmel_6-1697696158090.png

 

 

 

0 Likes
Message 8 of 8

g.georgiades
Advocate
Advocate

I am seeing success by programmatically selecting all the tweaks in the active storyboard and using inventor command to delete them. (After you undo the associativity and no scene is active)

 

When you physically hit delete key, it calls AppDeleteCmd, not some TweakDelete command so there must be something under the hood that is different.

 

Side note while testing this: i found that using Publication.Storyboards.Add creates a new storyboard, but it is invisible to the user 🙂

 

	Dim doc As PresentationDocument = ThisApplication.ActiveDocument
	Dim pubs As New List(Of Publication) 'Essentially PresentationDocument.Publications

	Dim topnode = doc.BrowserPanes.Item("Model").TopNode

	For Each node As BrowserNode In topnode.BrowserNodes 'These are all the scene nodes
		If node.NativeObject IsNot Nothing AndAlso TypeOf node.NativeObject Is Publication Then
			pubs.Add(node.NativeObject)
		End If
	Next

	Dim activePub = pubs.First(Function(p) p.DisplayName = doc.ActiveScene.Name) 'Essentially PresentationDocument.ActivePublication
	Dim activeStoryBoard = activePub.ActiveStoryboard

	ThisDoc.Document.SelectSet.Clear()
	For Each twk In activeStoryBoard.Tweaks
		ThisDoc.Document.SelectSet.Select(twk)
	Next

	ThisApplication.CommandManager.ControlDefinitions.Item("AppDeleteCmd").Execute2(True)

 

0 Likes