Vault Customization

Active Contributor
Posts: 31
Registered: ‎06-08-2011
Message 1 of 3 (273 Views)
Accepted Solution

Remove tertiary links

273 Views, 2 Replies
10-09-2012 06:51 PM

Historically we have included views of parts on our assembly drawings. Now when we come to itemise the parts we are getting 100+ drawings referenced to the item as tertiary links. I want to write a little routine to do this but can't get the UpdateandCommitItem action to work. I am asusming its something to do with the last parameter (active inputs)


here's the function. I have used active input values of 0,1,2 and 4 to no avail

       /// <summary>
        /// Remove the unwanted tertiary linked files. These are extracted when a part is explicitly referenced in a Drawing 
        /// </summary>
        /// <param name="itemId"></param>
        public void RemoveUnwantedTertiaryLinks(long itemId)
            Item selItem = m_itemSvc.GetItemsByIds(new long[] { itemId })[0];

            //Get the primary linked file
            ItemFileAssoc primaryFile = m_itemSvc.GetItemFileAssociationsByItemIds(new long[] { selItem.Id }, ItemFileLnkTypOpt.Primary)[0];

            //Get all the tertiary assocs for the item
            ItemFileAssoc[] itemFileAssocs = m_itemSvc.GetItemFileAssociationsByItemIds(new long[] { selItem.Id }, ItemFileLnkTypOpt.Tertiary);

            IEnumerable<long> fileIds = from fileassoc in itemFileAssocs select fileassoc.CldFileId;
            File[] files = m_docSvc.GetFilesByIds(fileIds.ToArray<long>());

            File drawingFile = null;
            //now match the drawing name to the primary fiule name and remove all the others
            foreach (File fle in files)
                //If the filename matches either the item number or the primary linked filename then keep it
                if (System.IO.Path.GetFileNameWithoutExtension(fle.Name).ToLower() == System.IO.Path.GetFileNameWithoutExtension(primaryFile.FileName).ToLower() || System.IO.Path.GetFileNameWithoutExtension(fle.Name).ToLower() == selItem.ItemNum.ToLower())
                    drawingFile = fle;
                if (drawingFile != null) break;

            //now edit the item to update links
            Item editItem = m_itemSvc.EditItem(selItem.RevId);
            Item updateItem = m_itemSvc.UpdateAndCommitItem(editItem, primaryFile.CldFileId, false, null, null, null, null, null, new long[] { drawingFile.Id }, 1);

 Any one got any pointers?


Greg Heeley
CAD Administrator
temperzone Ltd
Inventor Pro, Vault Pro, ACADE
Posts: 806
Registered: ‎12-12-2006
Message 2 of 3 (264 Views)

Re: Remove tertiary links

10-10-2012 04:57 AM in reply to: g.heeley

You are correct, it's related to the "active inputs" parameter.  Unfortunately, you have run into another documentation bug.  The CHM doesn't mention that 8 is the bit value for making the 'tertLinks' input active.


In the code you showed, 'secondary' is the only active field because you pass in 1.  If you want both 'secondary' and 'tertLinks' to be active, pass in 9.


Doug Redmond
Software Engineer
Autodesk, Inc.

Valued Mentor
Posts: 535
Registered: ‎01-14-2010
Message 3 of 3 (182 Views)

Re: Remove tertiary links

12-16-2012 02:32 AM in reply to: g.heeley

After you have deleted those links don't you have problem that they return on each Item update?

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.