Exemplo n.º 1
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig    jig = new InputJig();
            InputResult res = jig.SelectObject("Select Line");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }

            LineSeg3d line = res.Geometry.LineSeg;

            _pnt1 = line.StartPoint;
            _pnt2 = line.EndPoint;

            McObjectId id        = res.ObjectId;
            DbGeometry selection = id.GetObject();

            //if (selection.IsKindOf(DbPolyline.TypeID))
            //{
            //    MessageBox.Show("poly");
            //}
            //else if (selection.IsKindOf(DbLine.TypeID))
            //{
            //    MessageBox.Show("line");
            //}
            //else
            //{
            //    MessageBox.Show("Objecttype isn't valid");
            //    DbEntity.Erase();
            //    return hresult.e_Fail;
            //}
            DbEntity.AddToCurrentDocument();
            return(hresult.s_Ok);
        }
Exemplo n.º 2
0
    public McRealObjectHelper(SerializationInfo info, StreamingContext context)
    {
        McObjectId id = (McObjectId)info.GetValue("ID", typeof(McObjectId));

        m_realObject = getObject(id);
        if (m_realObject == null)
        {
            return;
        }
        Type t = m_realObject.GetType();

        MemberInfo[]      members            = FormatterServices.GetSerializableMembers(t, context);
        List <MemberInfo> deserializeMembers = new List <MemberInfo>(members.Length);
        List <object>     data = new List <object>(members.Length);

        foreach (MemberInfo mi in members)
        {
            Type dataType = null;
            if (mi.MemberType == MemberTypes.Field)
            {
                FieldInfo fi = mi as FieldInfo;
                dataType = fi.FieldType;
            }
            else if (mi.MemberType == MemberTypes.Property)
            {
                PropertyInfo pi = mi as PropertyInfo;
                dataType = pi.PropertyType;
            }
            try
            {
                if (dataType != null)
                {
                    data.Add(info.GetValue(mi.Name, dataType));
                    deserializeMembers.Add(mi);
                }
            }
            catch (SerializationException)
            {
                //some fiels are missing, new version, skip this fields
            }
        }
        FormatterServices.PopulateObjectMembers(m_realObject, deserializeMembers.ToArray(), data.ToArray());
    }
Exemplo n.º 3
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig    jig = new InputJig();
            InputResult res = jig.SelectObject("Select Line");

            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }

            LineSeg3d line = res.Geometry.LineSeg;

            poly = new Polyline3d(line);

            McObjectId id        = res.ObjectId;
            DbGeometry selection = id.GetObject();

            DbEntity.AddToCurrentDocument();
            return(hresult.s_Ok);
        }
Exemplo n.º 4
0
        public override hresult PlaceObject(PlaceFlags lInsertType)
        {
            InputJig          jig           = new InputJig();
            List <McObjectId> SelectObjects = jig.SelectObjects("Select Object");

            //InputResult res = jig.SelectObject("Select a Polyline");
            //McObjectId id = SelectObjects[0];//.ObjectId;
            //DbGeometry selection = id.GetObject();
            if (SelectObjects.Count == 0)
            {
                DbEntity.Erase();
                return(hresult.e_Fail);
            }

            McDocument document = McDocumentsManager.GetActiveDoc();
            McDocument block    = document.CreateBlock("ArrayBlock", true);

            _block_name = block.Name;

            InputResult res = jig.GetPoint("Select Base Point:");

            foreach (McObjectId obj in SelectObjects)
            {
                McDbObject item = obj.GetObject();
                item.Entity.DbEntity.Transform(Matrix3d.Displacement(res.Point.GetAsVector().MultiplyBy(-1)));
                block.AddObject(item.Clone());
            }

            _idRef = document.GetBlock(_block_name);

            res = jig.GetPoint("Select first point:");
            if (res.Result != InputResult.ResultCode.Normal)
            {
                return(hresult.e_Fail);
            }
            _pnt1 = res.Point;
            foreach (McObjectId obj in SelectObjects)
            {
                McDbObject item = obj.GetObject();
                item.Erase();
            }

            McBlockRef blockref = new McBlockRef();

            blockref.BlockName   = _block_name;
            blockref.InsertPoint = res.Point;
            blockref.DbEntity.AddToCurrentDocument();
            _blockRef.Add(blockref);
            _blockRef.Add(_blockRef[0].DbEntity.Clone());
            _blockRef.Add(_blockRef[0].DbEntity.Clone());
            DbEntity.AddToCurrentDocument();
            //Exclude this from osnap to avoid osnap to itself
            jig.ExcludeObject(ID);
            //Monitor mouse move
            jig.MouseMove = (s, a) => {
                TryModify();
                _pnt2 = a.Point;
                DbEntity.Update();
            };

            res = jig.GetPoint("Select second point:", res.Point);
            if (res.Result != InputResult.ResultCode.Normal)
            {
                DbEntity.Erase();
                blockref.DbEntity.Erase();
                return(hresult.e_Fail);
            }
            _pnt2 = res.Point;

            Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            PromptIntegerOptions opts = new PromptIntegerOptions("Enter Count number: ");

            opts.AllowNegative = false;
            opts.AllowZero     = false;
            opts.DefaultValue  = 1;
            PromptIntegerResult pr = ed.GetInteger(opts);

            if (PromptStatus.OK == pr.Status)
            {
                ed.WriteMessage("You entered: " + pr.StringResult);
                _count = pr.Value;

                _blockRef.Add(blockref.DbEntity.Clone());
                _blockRef[1].InsertPoint = res.Point;
                _blockRef[1].DbEntity.AddToCurrentDocument();
            }
            else
            {
                _count = 1;

                _blockRef.Add(blockref.DbEntity.Clone());
                _blockRef[1].InsertPoint = res.Point;
                _blockRef[1].DbEntity.AddToCurrentDocument();
            }

            for (int i = 1; i < Count; i++)
            {
                _blockRef.Add(_blockRef[0].DbEntity.Clone());
            }

            return(hresult.s_Ok);
        }
Exemplo n.º 5
0
 virtual object getObject(McObjectId id)
 {
     return(id.GetObject());
 }