Exemple #1
0
        public static BCOM.Attachment AsAttachment(this BCOM.ModelReference model,
                                                   BCOM.ModelReference owner = null)
        {
            owner = owner ?? App.ActiveModelReference;

            foreach (BCOM.Attachment attach in owner.Attachments)
            {
                // равенство работает только для версии V8i
                if (attach.MdlModelRefP() == model.MdlModelRefP())
                {
                    return(attach);
                }
            }
            return(null);
        }
/*-----------------------------------------------------------------------------*/
        /// <summary>
        /// checks to see if there is an imodel.
        /// </summary>
        /// <param name="pModel">the root model to search for references</param>
        /// <returns>true the model has an i-model referenced in.</returns>
/*-----------------------------------------------------------------------------*/
        public static bool HasIModelReference(BCOM.ModelReference pModel)
        {
            try
            {
                if (!pModel.IsAttachment ||
                    (pModel.IsAttachment && !pModel.AsAttachment.IsMissingFile))
                {
                    if (1 == IsIModel(pModel.MdlModelRefP()))
                    {
                        return(true);
                    }
                }

                foreach (BCOM.Attachment oAttachment in pModel.Attachments)
                {
                    BCOM.ModelReference rModel = (BCOM.ModelReference)oAttachment;

                    if (!oAttachment.IsMissingFile)
                    {
                        if (1 == IsIModel(rModel.MdlModelRefP()))
                        {
                            return(true);
                        }
                    }

                    foreach (BCOM.Attachment a in oAttachment.Attachments)
                    {
                        return(HasIModelReference((BCOM.ModelReference)a));
                    }
                }
            }
            catch (System.Reflection.TargetException te)
            {
                ComApp.MessageCenter.AddMessage("Exception on the isIModel call",
                                                "The Has IModel code has failed to detect an i-model",
                                                BCOM.MsdMessageCenterPriority.Error, false);
            }

            //if it makes it here must not be an imodel
            return(false);
        }
Exemple #3
0
        public static BCOM.Attachment AsAttachment(this BCOM.ModelReference model,
                                                   BCOM.ModelReference owner = null)
        {
            owner = owner ?? App.ActiveModelReference;

            foreach (BCOM.Attachment attach in owner.Attachments)
            {
                //if (attach.IsMissingFile || attach.IsMissingModel)
                //    continue;
                try
                {
                    // attach.DesignFile в некоторых случаях выбрасывает ошибку
                    // attach.IsMissingFile - не помогает
                    if (attach.DesignFile.MdlModelRefP() == model.MdlModelRefP())
                    {
                        return(attach);
                    }
                }
                catch (Exception) {}
            }
            return(null);
        }
Exemple #4
0
 public static DgnModelRef AsDgnModelRef(this BCOM.ModelReference model)
 {
     return(DgnModel.GetModelRef((IntPtr)model.MdlModelRefP()));
 }