Hello,
I would like to hide / show all Trails via API.
Tried it with the "PresentationExplodedViews" Object, but there is the Trail Visibility is a read only Object.
Is there a way to get access via API?
Thanks
Regards
Daniel
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Hello Daniel,
I tried to change the visibility of the trails, but couldn't.
There are undocumented APIs such as PublicationTweak or PublicationTrailSegment.
I found that PublicationTrailSegment.Visible is related to the visibility of the Trail, but it seems to be read-only.
Sub ChangeAllTrailVisibility(Optional showTrail As Boolean = True) Dim oPrDoc As PresentationDocument Set oPrDoc = ThisApplication.ActiveDocument Dim oBNs As BrowserNodesEnumerator Set oBNs = oPrDoc.BrowserPanes(1).TopNode.BrowserNodes(1).BrowserNodes(2).BrowserNodes Dim oBN As BrowserNode For Each oBN In oBNs If TypeOf oBN.NativeObject Is PublicationTweak Then Dim oPT As PublicationTweak Set oPT = oBN.NativeObject Dim oPTSeg As PublicationTrailSegment For Each oPTSeg In oPT.TrailSegments ' PublicationTrailSegment.Visible can be read. Debug.Print oPTSeg.Visible ' But we cannot write on it. 'oPTSeg.Visible = showTrail Next oPTSeg End If Next oBN End Sub
So I think that we cannot change the visibility of the trails.
=====
Hideo Yamada
Hello Hideo,
Thanks for your Answer.
In the meantime I found an object in the Inventor Api Help that can affect the visibility of the path segment.
Found the object in the Inventor API object model but can not get back any path segments.
Here is a Screenshot from a Watch in VBA
VBA Code:
Public Sub Test()
Dim PresDoc As PresentationDocument
Set PresDoc = ThisApplication.ActiveDocument
Dim Scene As PresentationScene
Set Scene = PresDoc.Scenes(1)
Dim SnapShot As PresentationSnapshotView
Set SnapShot = Scene.SnapshotViews(1)
'Dim Trails As PresentationTrails
'Set Trails = SnapShot.Trails
End Sub
Thanks
Regards
Daniel
Thanks for writing it in forum,
I tried to set hide or show trail using below VBA code. Fails to set value for PresentationTrailSegment.Visible Property.
Public Sub Test() Dim PresDoc As PresentationDocument Set PresDoc = ThisApplication.ActiveDocument Dim Scene As PresentationScene Set Scene = PresDoc.Scenes(1) Dim SnapShot As PresentationSnapshotView Set SnapShot = Scene.SnapshotViews(1) Dim Trails As PresentationTrail Set Trails = SnapShot.Trails.Item(9) Trails.Segments.Item(1).Visible = False End Sub
To address this, a change request (INVGEN - 35227) is created with engineering team.
Thanks and regards,
Hello,
Thanks for your time to test this usecase.
Is there any timeframe for this fix?
Regards
Daniel
I will let you know once it is implemented.
Thanks and regards,
Hi Daniel,
Do you want to hide the trails in the storyboard or in a snapshot view? As you can see the current API PresentationSnapshotView.Trails only returns the trails in a PresentationSnapshotView, we have not exposed the API for storyboard yet, so if you want to hide all the trails in the storyboard it would be a new wish for us. I just want to check if we implement the PresentationTrailSegment.Visible as R/W can help you or not.
Hello Rocky,
thanks for you replay.
For shure it would be nice to hide all Trails in the StoryBoard, but if I can hide the Trails via Snapshot, I can iterate programmatically through all snapshots. So for me the snapshot is enough.
Thanks
Daniel
Thanks Daniel, this will help us to estimate this requirement.
Hi Daniel,
In Inventor 2021 you can try below VBA to see if it works for you:
Sub TurnOffTrailsInSnapshotView()
Dim oPresDoc As PresentationDocument
Set oPresDoc = ThisApplication.ActiveDocument
Dim oScene As PresentationScene
Set oScene = oPresDoc.Scenes(1)
Dim oSnapShot As PresentationSnapshotView
Set oSnapShot = oScene.SnapshotViews(1)
' we need to break the associativity between the snapshot view and storyboard before editing it
oSnapShot.StoryboardAssociative = False
' enter the edit mode for snapshot view(eitherwise the edit will fail)
oSnapShot.Edit
Dim oTrail As PresentationTrail
For Each oTrail In oSnapShot.Trails
Dim oSeg As PresentationTrailSegment
For Each oSeg In oTrail.Segments
Debug.Print oSeg.Visible
oSeg.Visible = False
Debug.Print oSeg.Visible
Next
Next
End Sub
Hello Rocky,
Thank you so much. It works now as expected in Inventor 2021.
Regards
Daniel
Can't find what you're looking for? Ask the community or share your knowledge.