////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void CreateOccurrenceTag(AssemblyDocument AsmDocument, PartFeature PartFeature, ComponentOccurrence occurrence)
        {
            AttributeSet set = PartFeature.AttributeSets[_AttributeSet];

            Byte[] contextData = set["ContextData"].Value as Byte[];

            int keyContext = AsmDocument.ReferenceKeyManager.LoadContextFromArray(ref contextData);

            Byte[] refKey = new byte[] { };

            occurrence.GetReferenceKey(ref refKey, keyContext);

            set.Add("OccurrenceRefKey", ValueTypeEnum.kByteArrayType, refKey);


            PartDocument doc = PartFeature.Parent.Document as PartDocument;

            set = doc.ComponentDefinition.AttributeSets[_AttributeSet];

            string srcDocPath = set["SourcePartDoc"].Value as string;

            PartDocument srcDoc = FeatureUtilities.Application.Documents.Open(srcDocPath, false) as PartDocument;


            foreach (PartFeature feature in doc.ComponentDefinition.Features)
            {
                if (feature.AttributeSets.get_NameIsUsed(_AttributeSet))
                {
                    AttributeSet setFeature = feature.AttributeSets[_AttributeSet];

                    string AsmFeature = setFeature["AsmFeature"].Value as string;

                    if (!setFeature.get_NameIsUsed("OccurrenceRefKey"))
                    {
                        ObjectCollection collec = srcDoc.AttributeManager.FindObjects(_AttributeSet, "AsmFeature", AsmFeature);

                        if (collec.Count > 0)
                        {
                            PartFeature srcFeature = collec[1] as PartFeature;

                            object val = srcFeature.AttributeSets[_AttributeSet]["OccurrenceRefKey"].Value;

                            setFeature.Add("OccurrenceRefKey", ValueTypeEnum.kByteArrayType, val);
                        }
                    }
                }
            }

            srcDoc.Close(true);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void CreatePartFeatureTag(AssemblyDocument AsmDocument,
                                                PartFeature AsmFeature,
                                                PartFeature PartFeature,
                                                ComponentOccurrence Occurrence)
        {
            if (PartFeature == null)
            {
                return;
            }

            AttributeSet set = PartFeature.AttributeSets.Add(_AttributeSet, true);

            set.Add("AsmFile", ValueTypeEnum.kStringType, AsmDocument.FullFileName);
            set.Add("AsmDoc", ValueTypeEnum.kStringType, AsmDocument.FullDocumentName);
            set.Add("AsmIntName", ValueTypeEnum.kStringType, AsmDocument.InternalName);
            set.Add("AsmFeature", ValueTypeEnum.kStringType, AsmFeature.Name);


            Byte[] contextData = new byte[] { };

            int keyContext = AsmDocument.ReferenceKeyManager.CreateKeyContext();

            AsmDocument.ReferenceKeyManager.SaveContextToArray(keyContext, ref contextData);

            set.Add("ContextData", ValueTypeEnum.kByteArrayType, contextData);


            Byte[] featureRefKey = new byte[] { };

            AsmFeature.GetReferenceKey(ref featureRefKey, keyContext);

            set.Add("AsmFeatureRefKey", ValueTypeEnum.kByteArrayType, featureRefKey);


            Byte[] occRefKey = new byte[] { };

            Occurrence.GetReferenceKey(ref occRefKey, keyContext);

            set.Add("OccurrenceRefKey", ValueTypeEnum.kByteArrayType, occRefKey);
        }