コード例 #1
0
        public bool FabSetItemProp(ResultBuffer args)
        {
            bool    ret = false;
            dynamic res = null;

            if (args != null)
            {
                TypedValue[] argarray = args.AsArray();
                ObjectId     ent;
                string       path  = "";
                dynamic      value = null;
                dynamic      itm   = null;
                if (argarray.Length >= 2)
                {
                    if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.ObjectId)
                    {
                        ent = (ObjectId)argarray[0].Value;
                        try { itm = Autodesk.Fabrication.Job.GetFabricationItemFromACADHandle(ent.Handle.ToString()); }
                        catch (System.Exception) { }
                    }
                    else if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.Text)
                    {
                        itm = (string)argarray[0].Value;
                        if (itm.StartsWith("$") == true && VarCache.ContainsKey(hand.VariableName(itm)) == true)
                        {
                            itm = VarCache[hand.VariableName(itm)];
                        }
                    }
                    if (argarray.Length >= 2 && argarray[1].TypeCode == (int)LispDataType.Text)
                    {
                        path = (string)argarray[1].Value;
                    }
                    if (argarray.Length >= 3)
                    {
                        value = hand.ConvertFromRB(argarray[2]);
                    }
                }
                if (itm != null && path.Length > 1)
                {
                    res = Sequencing.GenericPropertySetter(itm, new List <string>(path.Split('.')), value);
                }
            }
            return(ret);
        }
コード例 #2
0
        public dynamic FabGetDBItem(ResultBuffer args)
        {
            ResultBuffer ret = new ResultBuffer();
            object       res = null;

            if (args != null)
            {
                TypedValue[] argarray = args.AsArray();
                ObjectId     ent;
                string       path    = "";
                string       varName = "";
                dynamic      itm     = null;
                if (argarray.Length >= 2)
                {
                    if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.ObjectId)
                    {
                        ent = (ObjectId)argarray[0].Value;
                        try
                        {
                            itm = Autodesk.Fabrication.Job.GetFabricationItemFromACADHandle(ent.Handle.ToString());
                        }
                        catch (System.Exception) { }
                    }
                    else if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.Text)
                    {
                        itm = (string)argarray[0].Value;
                        if (itm.StartsWith("$") == true && VarCache.ContainsKey(hand.VariableName(itm)) == true)
                        {
                            itm = VarCache[hand.VariableName(itm)];
                        }
                    }
                    if (argarray.Length >= 2 && argarray[1].TypeCode == (int)LispDataType.Text)
                    {
                        path = (string)argarray[1].Value;
                    }
                    if (argarray.Length >= 3 && argarray[2].TypeCode == (int)LispDataType.Text)
                    {
                        varName = hand.VariableName((string)argarray[2].Value);
                    }
                }
                if (itm != null && path.Length > 1)
                {
                    res = Sequencing.GenericPropertyGetter(itm, new List <string>(path.Split('.')));
                    if (varName.Length >= 1)
                    {
                        if (VarCache.ContainsKey(varName) == true)
                        {
                            VarCache[varName] = res;
                        }
                        else
                        {
                            VarCache.Add(varName, res);
                        }
                    }
                }
            }
            if (res != null)
            {
                foreach (TypedValue x in hand.ConvertToRB(res))
                {
                    ret.Add(x);
                }
            }
            else
            {
                ret.Add(new TypedValue((int)LispDataType.Nil));
            }
            if (ret.AsArray().Length > 1)
            {
                return(ret);
            }
            else
            {
                return(ret.AsArray()[0]);
            }
        }
コード例 #3
0
        public dynamic FabDumpItem(ResultBuffer args)
        {
            Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            List <string> res = new List <string>();
            ObjectId      ent;
            string        path       = "";
            int           OutputType = 3;
            dynamic       itm        = null;

            if (args != null)
            {
                TypedValue[] argarray = args.AsArray();
                if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.ObjectId)
                {
                    ent = (ObjectId)argarray[0].Value;
                    try { itm = Autodesk.Fabrication.Job.GetFabricationItemFromACADHandle(ent.Handle.ToString()); }
                    catch (System.Exception) { }
                }
                else if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.Text)
                {
                    itm = (string)argarray[0].Value;
                    if (itm.StartsWith("$") == true && VarCache.ContainsKey(hand.VariableName(itm)) == true)
                    {
                        itm = VarCache[hand.VariableName(itm)];
                    }
                }
                if (argarray.Length >= 2 && argarray[1].TypeCode == (int)LispDataType.Text)
                {
                    path = (string)argarray[1].Value;
                }
                if (argarray.Length >= 3 && argarray[2].TypeCode == (int)LispDataType.Int16)
                {
                    OutputType = Convert.ToInt32(argarray[2].Value);
                }

                if (itm != null && path.Length > 1)
                {
                    res = Sequencing.GetReflectedTypesList(itm, new List <string>(path.Split('.')));
                    if (res.Count >= 1)
                    {
                        ed.WriteMessage("\n\n");
                        foreach (string s in res)
                        {
                            if (s.StartsWith("Property:") == true)
                            {
                                if (OutputType == 1 || OutputType == 3)
                                {
                                    ed.WriteMessage(s + "\n");
                                }
                            }
                            else if (s.StartsWith("Method:") == true)
                            {
                                if (OutputType == 2 || OutputType == 3)
                                {
                                    ed.WriteMessage(s + "\n");
                                }
                            }
                        }
                    }
                }
            }
            ResultBuffer rb = new ResultBuffer();

            rb.Add(new TypedValue((int)LispDataType.ListBegin));
            foreach (string s in res)
            {
                rb.Add(new TypedValue((int)LispDataType.Text, s));
            }
            rb.Add(new TypedValue((int)LispDataType.ListEnd));
            if (OutputType >= 1 && OutputType <= 3)
            {
                return(null);
            }
            else
            {
                return(rb);
            }
        }
コード例 #4
0
        public object FabInvokeItem(ResultBuffer args)
        {
            ResultBuffer ret  = new ResultBuffer();
            dynamic      pres = null;
            dynamic      mres = null;

            Autodesk.AutoCAD.Geometry.Point3dCollection pts = new Autodesk.AutoCAD.Geometry.Point3dCollection();
            if (args != null)
            {
                TypedValue[]  argarray = args.AsArray();
                ObjectId      ent;
                string        path     = "";
                string        methName = "";
                string        varName  = "";
                List <object> methArgs = new List <object>();
                dynamic       itm      = null;
                if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.ObjectId)
                {
                    ent = (ObjectId)argarray[0].Value;
                    try
                    {
                        itm = Autodesk.Fabrication.Job.GetFabricationItemFromACADHandle(ent.Handle.ToString());
                        if (itm.Connectors?.Count >= 1)
                        {
                            Transaction tr  = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction();
                            DBObject    dbo = tr.GetObject((ObjectId)ent, OpenMode.ForRead);
                            (dbo as Entity).GetStretchPoints(pts);
                            tr.Dispose();
                        }
                    }
                    catch (System.Exception) { }
                }
                else if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.Text)
                {
                    itm = (string)argarray[0].Value;
                    if (itm.StartsWith("$") == true && VarCache.ContainsKey(hand.VariableName(itm)) == true)
                    {
                        itm = VarCache[hand.VariableName(itm)];
                    }
                }
                if (argarray.Length >= 2 && argarray[1].TypeCode == (int)LispDataType.Text)
                {
                    path = (string)argarray[1].Value;
                }
                if (argarray.Length >= 3 && argarray[2].TypeCode == (int)LispDataType.Text)
                {
                    methName = hand.VariableName((string)argarray[2].Value);
                }
                methArgs = hand.ExtractListValues(argarray);
                if (argarray[argarray.Length - 1].TypeCode == (int)LispDataType.Text)
                {
                    varName = hand.VariableName(hand.GetVarNameFromArgs(argarray[argarray.Length - 1]));
                }
                if (itm != null && path.Length > 1 && methName.Length >= 1)
                {
                    pres = Sequencing.GenericPropertyGetter(itm, new List <string>(path.Split('.')));
                    mres = Sequencing.GenericMethodInvoke(pres, methName, methArgs);
                    if (methName == "GETCONNECTORENDPOINT")
                    {
                        mres = pts.Count >= 1 ? pts : null;
                    }
                    if (varName.Length >= 1)
                    {
                        if (VarCache.ContainsKey(varName) == true)
                        {
                            VarCache[varName] = mres;
                        }
                        else
                        {
                            VarCache.Add(varName, mres);
                        }
                    }
                }
            }
            if (mres != null)
            {
                foreach (TypedValue x in hand.ConvertToRB(mres))
                {
                    ret.Add(x);
                }
                if (ret.AsArray().Length > 1)
                {
                    return(ret);
                }
                else
                {
                    return(ret.AsArray()[0]);
                }
            }
            else
            {
                return(true);
            }
        }