Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete model

9 REPLIES 9
Reply
Message 1 of 10
bthatcher
880 Views, 9 Replies

Delete model

Is it posible to delete or remove an appended model? I cant find any obvious was through the .NET api. Thanks. 

9 REPLIES 9
Message 2 of 10
xiaodong_liang
in reply to: bthatcher
Message 3 of 10

Whats the dumb down way to delete apended files in Navisworks. In 2013 I could right click delete? 2014 has no option to delete. I am in a Nwf file.

 

Message 4 of 10

Hi,

 

although this sounds like a product question, I checked Nw2014 quickly. It looks the [delete] is still avaiable there. is this what you are looking for?

 

ADNTest.jpg

Message 5 of 10
rtonin
in reply to: xiaodong_liang

hy all,

Is there another way to remove an appended model file without use Autodesk.Navisworks.Api.Interop.ComApi state.DeleteSelectedFiles() method?

this comAPI method not work properly on Naviswors 2022.

Rolando

Message 6 of 10
ulski1
in reply to: rtonin

What do you mean it doesn't work in Navisworks 2022? It never worked very well - did it get worse?
Message 7 of 10
rtonin
in reply to: ulski1

this is my mplementation method:

 

public void RemoveModelFromDocument(Autodesk.Navisworks.Api.Document doc, Autodesk.Navisworks.Api.Model modello)
{
if(modello != null)
{
try
{
doc.CurrentSelection.CopyFrom(modello.RootItem.AncestorsAndSelf);

Autodesk.Navisworks.Api.Interop.ComApi.InwOpState10 state =
ComApiBridge.State;

state.DeleteSelectedFiles();
}
catch (Exception e)
{
throw e;
}
}
}

when state.DeleteSelectedFiles() was called it raise an "Naviswork unknown error" exception. If I remove throw e; line model in not removed from document.

 

Rolando

Message 8 of 10
ulski1
in reply to: rtonin

I think the reason it doesn't work is you are parsing and object collection instead of a rootitem
try this change:
doc.CurrentSelection.CopyFrom(modello.RootItem);
Message 9 of 10
rtonin
in reply to: ulski1

In the above code I substitute selection with this line of code:

 

doc.CurrentSelection.CopyFrom(new List<ModelItem>() { model.RootItem });

 

but the same Exception is always raised.

In the meantime I have found a solution. I discovered that this exception is raised when the model I want to remove is the unique model in document's model list. Therefore I append a new model and after I can remove the old model and all work fine.

Thanks a lot for your suggestion.

Rolando

Rolando

Message 10 of 10
ulski1
in reply to: rtonin

You can never remove all models - Navisworks as a minimun need to hold one model

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report