Esempio n. 1
0
        public virtual bool TryGet(string name, out IXFeature ent)
        {
            IFeature feat;

            switch (Document.Model)
            {
            case IPartDoc part:
                feat = part.FeatureByName(name) as IFeature;
                break;

            case IAssemblyDoc assm:
                feat = assm.FeatureByName(name) as IFeature;
                break;

            case IDrawingDoc drw:
                feat = drw.FeatureByName(name) as IFeature;
                break;

            default:
                throw new NotSupportedException();
            }

            if (feat != null)
            {
                ent = SwObject.FromDispatch <SwFeature>(feat, Document);
                return(true);
            }
            else
            {
                ent = null;
                return(false);
            }
        }
Esempio n. 2
0
        protected override void ExtractRawParameters(IXCustomFeature feat, IXDocument doc,
                                                     out Dictionary <string, object> parameters,
                                                     out IXDimension[] dimensions, out IXSelObject[] selection, out IXBody[] editBodies)
        {
            object retParamNames  = null;
            object retParamValues = null;
            object paramTypes     = null;
            object retSelObj;
            object selObjType;
            object selMarks;
            object selDrViews;
            object compXforms;

            var featData = ((SwMacroFeature)feat).FeatureData;

            featData.GetParameters(out retParamNames, out paramTypes, out retParamValues);
            featData.GetSelections3(out retSelObj, out selObjType, out selMarks, out selDrViews, out compXforms);

            dimensions = GetDimensions(feat);

            var editBodiesObj = featData.EditBodies as object[];

            if (editBodiesObj != null)
            {
                editBodies = editBodiesObj.Cast <IBody2>()
                             .Select(b => SwObject.FromDispatch <SwBody>(b, (SwDocument)doc)).ToArray();
            }
            else
            {
                editBodies = null;
            }

            var paramNames  = retParamNames as string[];
            var paramValues = retParamValues as string[];

            if (paramNames != null)
            {
                parameters = new Dictionary <string, object>();

                for (int i = 0; i < paramNames.Length; i++)
                {
                    parameters.Add(paramNames[i], paramValues[i]);
                }
            }
            else
            {
                parameters = null;
            }

            var selObjects = retSelObj as object[];

            if (selObjects != null)
            {
                selection = selObjects.Select(s => SwObject.FromDispatch <SwSelObject>(s, (SwDocument)doc)).ToArray();
            }
            else
            {
                selection = null;
            }
        }
Esempio n. 3
0
        public bool TryGet(string name, out IXComponent ent)
        {
            var comp = m_Assm.Assembly.GetComponentByName(name);

            if (comp != null)
            {
                ent = SwObject.FromDispatch <SwComponent>(comp, m_Assm);
                return(true);
            }
            else
            {
                ent = null;
                return(false);
            }
        }
Esempio n. 4
0
        public bool TryGet(string name, out IXSheet ent)
        {
            var sheet = m_Doc.Drawing.Sheet[name];

            if (sheet != null)
            {
                ent = SwObject.FromDispatch <SwSheet>(sheet, m_Doc);
                return(true);
            }
            else
            {
                ent = null;
                return(false);
            }
        }
Esempio n. 5
0
        public bool TryGet(string name, out IXComponent ent)
        {
            var comp = GetChildren().FirstOrDefault(c => string.Equals(GetRelativeName(c), name, StringComparison.CurrentCultureIgnoreCase));

            if (comp != null)
            {
                ent = SwObject.FromDispatch <SwComponent>(comp, m_Assm);
                return(true);
            }
            else
            {
                ent = null;
                return(false);
            }
        }
Esempio n. 6
0
        public bool TryGet(string name, out IXConfiguration ent)
        {
            var conf = m_Doc.Model.GetConfigurationByName(name);

            if (conf != null)
            {
                ent = SwObject.FromDispatch <SwConfiguration>((IConfiguration)conf, m_Doc);
                return(true);
            }
            else
            {
                ent = null;
                return(false);
            }
        }
Esempio n. 7
0
 public static ISwTempBody ToTempBody(this ISwBody body)
 => SwObject.FromDispatch <SwTempBody>(body.Body.ICopy());
 private SwSelObject ToSelObject(object disp)
 {
     return((SwSelObject)SwObject.FromDispatch(disp, m_App.IActiveDoc2));
 }