delete or remove an appended model

By Xiaodong Liang

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

Solution

Suppose we have one document in which there is only one modal from one file. We can run Append or Merge to add more files. So we would have “several files” in one document.Currently, only COM API provides the ability to remove the models.  It can delete any files like you select the files in UI and press delete. The whole contents of the deleted file will be removed. The code is as below,  assume we want to delete the 3rd file in the document.

public override int Execute(params string[] parameters)    {         Nw.Document doc =                  Nw.Application.ActiveDocument;         doc.CurrentSelection.CopyFrom(doc.Models[2].                   RootItem.AncestorsAndSelf);         ComApi.InwOpState10 state =                   ComApiBridge.ComApiBridge.State;         state.DeleteSelectedFiles();         return 0;    }

Comments

4 responses to “delete or remove an appended model”

  1. It is not always clear as to which product the article refers (NW, Revit, etc). I’d suggest an opening comment so we don’t need to sleuth the code… Compliments on a very helpful blog. Dale

  2. xiaodong Avatar
    xiaodong

    Hi Dale,
    Thanks for the suggestion. At the bottom of each post, we added the catalog of the product and some other catalogs. Does this help you?
    In addition, sometimes I also need to search the blogs. What I did is to input the key words (e.g. “Navisworks delete”) and search. It works to me so far, though I do not know if there is a better trick.
    Regards,
    Xiaodong

  3. That was my very next guess ;) I originally posted that question to the forum. Thank you for the answer. Providing a link to this blog post as a response would have notified me and provided anyone else who came across my post the answer.
    Yea, this isn’t light reading. If i’m here it’s generally because I searched your blog or google brought me here. I would know exactly what I was reading pertained too. The catalog at the bottom is a bonus. And the ‘you also might like’ are great when I am just killing time. Thank you!!!

  4. oops, i apologize, you did leave a link to this blog in my post. I must have forgot to subscribe. I really appreciate you answering question right from the forum! For a long time there seemed to be very little involvement from Autodesk employees. I think it’s fantastic!

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading