How to Add/Edit Status or Comment of Viewpoint through the API?

How to Add/Edit Status or Comment of Viewpoint through the API?

Anonymous
Not applicable
3,704 Views
5 Replies
Message 1 of 6

How to Add/Edit Status or Comment of Viewpoint through the API?

Anonymous
Not applicable

Hi,

 

From GUI of Navisworks, right-click the desired viewpoint in the Saved Viewpoints window, and click Add Comment → Show dialog to Add or Edit: status or comment of SavedViewpoint.

I would like do that with API, but i don't know how to use the API to do this. How can i do it?

 

Any tips on these will be great help. Thanks in advance.

 

Regards,

MinhHN

0 Likes
Accepted solutions (1)
3,705 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

You can add comments to saveditems whenever they are not readonly (i.e. you are creating a new saved item, or created a copy of the saved item tree to edit it):

 

 SavedItem.Comments.Add(New Autodesk.Navisworks.Api.Comment(
                               commentText, commentStatus, commentAuthor))

Editing will be along these lines I assume...

Message 3 of 6

Anonymous
Not applicable
Accepted solution

Hi ngombault,

 

Firsts, thank you for the help!
I used code as above, an error occurred when executed: Object is Read-Only.
I tried other code as below, it executed successfully:

 

Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;
SavedItem oSVP = oDoc.SavedViewpoints.ToSavedItemCollection()[0];
Comment oComment = new Comment("My comments", CommentStatus.Approved);
oDoc.SavedViewpoints.AddComment(oSVP, oComment);

Regards,
MinhHN

 

Message 4 of 6

Anonymous
Not applicable

"I used code as above, an error occurred when executed: Object is Read-Only."

-> That's why I specified: "whenever they are not read only (i.e. you are creating a new saved item, or created a copy of the saved item tree to edit it)"

 

I didn't know about the shortcut you found, but I don't think it will let you edit an existing comment, in which case you'll have to create a copy and replace.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Ah ah, I understand. Thank again!

But, i used the code as above, and edited an existing comment OK ^^

0 Likes
Message 6 of 6

brian.k.smith
Advocate
Advocate

@Anonymous :  Thank you - this is working for me!

0 Likes