Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
sneha.sadaphal
134 Views, 0 Replies

Delete ImportedComponent from part environment

Hi,

I have inserted the step file as imported component in inventor part environment.

and also added one button to delete that imported component. 

but seems like the importedComponent.delete() is not implemented.

getting error for delete();

Is anyone have idea about this?

snehasadaphal_0-1691493588589.png

 

if (_document != null && _document.DocumentType == DocumentTypeEnum.kPartDocumentObject)
            {
                PartDocument _oPart = _document as PartDocument;
                var oPartCompdef = _oPart.ComponentDefinition;                
                ImportedComponents impComps = oPartCompdef.ReferenceComponents.ImportedComponents;
                foreach (ImportedComponent CompOcc in impComps)
                {                   
                  string fileUrn = CompOcc.Name.Replace(".stp","");
                   if (exchangeItem.ExchangeID.Contains(fileUrn))
                   {
                       CompOcc.Delete();
                   }
                }

            }