Ejemplo n.º 1
0
 /// <summary>
 /// Draws this instance
 /// </summary>
 /// <param name="tr">The active transaction.</param>
 protected override ObjectIdCollection DrawContent(Transaction tr)
 {
     try
     {
         ObjectIdCollection ids       = new ObjectIdCollection();
         Boolean            is2DBlock = !App.Riviera.Is3DEnabled;
         ObjectId           first     = this.Ids.OfType <ObjectId>().FirstOrDefault();
         RivieraLBlock      block     = this.Block as RivieraLBlock;
         var            doc           = Application.DocumentManager.MdiActiveDocument;
         BlockReference blkRef;
         LBlockType     blockType = this.GetBlockType();
         //Si ya se dibujo, el elemento tiene un id válido, solo se debe actualizar
         //el contenido.
         if (first.IsValid)
         {
             block.SetContent(blockType, is2DBlock, doc, tr);
             blkRef = first.GetObject(OpenMode.ForWrite) as BlockReference;
         }
         else
         {
             blkRef = block.Insert(doc, tr, blockType, this.Start.ToPoint3d(), this.Direction.Angle);
             if (!is2DBlock)
             {
                 UpdateBlockPosition(tr, blkRef);
             }
         }
         ids.Add(blkRef.Id);
         return(ids);
     }
     catch (Exception exc)
     {
         throw exc;
     }
 }
Ejemplo n.º 2
0
        private void InitContent(BordeoL135Panel panel, Transaction tr)
        {
            Dictionary <LBlockType, AutoCADBlock>
            blocks2D                 = new Dictionary <LBlockType, AutoCADBlock>(),
                blocks3D             = new Dictionary <LBlockType, AutoCADBlock>();
            RivieraLBlock rBlock     = (panel.Block as RivieraLBlock);
            AutoCADBlock  block2d    = new AutoCADBlock(String.Format(rBlock.Block2DName, rBlock.BlockName), rBlock.GetBlockFilePath(), tr);
            AutoCADBlock  block3d    = new AutoCADBlock(String.Format(rBlock.Block3DName, rBlock.BlockName), rBlock.GetBlockFilePath(false), tr);
            AutoCADBlock  varBlock2d = new AutoCADBlock(String.Format(SUFFIX_BLOCK2D, rBlock.VariantBlockName), rBlock.GetBlockFilePath(rBlock.VariantBlockName), tr);
            AutoCADBlock  varBlock3d = new AutoCADBlock(String.Format(SUFFIX_BLOCK3D, rBlock.VariantBlockName), rBlock.GetBlockFilePath(rBlock.VariantBlockName, false), tr);

            (panel.Block as RivieraLBlock).LoadBlocks(Application.DocumentManager.MdiActiveDocument, tr, out blocks2D, out blocks3D);
            string blockName        = block2d.Blockname.Substring(0, block2d.Blockname.Length - 2),
                   variantBlockName = varBlock2d != null?varBlock2d.Blockname.Substring(0, varBlock2d.Blockname.Length - 2) : null;

            AutoCADBlock blockRecord = blocks2D[LBlockType.LEFT_SAME_SIZE];

            blockRecord.Open(tr, OpenMode.ForWrite);
            blockRecord.Clear(tr);
            String code           = blockName.Substring(0, 6);
            Double frente1        = 18d.GetPanel135DrawingSize() * Math.Sin(Math.PI / 4),
                   frente2        = 18d.GetPanel135DrawingSize() + 18d.GetPanel135DrawingSize() * Math.Cos(Math.PI / 4);
            BlockReference blkRef = block2d.CreateReference(new Point3d(), 0);

            //Se rota 270°

            blkRef.TransformBy(Matrix3d.Rotation(-3 * Math.PI / 4, Vector3d.ZAxis, new Point3d()));
            Vector3d offset = new Vector3d(frente2, frente1, 0);

            //Offset BR2020
            if (code == CODE_PANEL_90)
            {
                offset = new Vector3d(offset.X + 0.1002d, offset.Y + 0.1002d, 0);
            }
            //Offset BR2030
            else
            {
                offset = new Vector3d(offset.X + 0.0709d, offset.Y + 0.0293d, 0);
            }
            //Se traslada el punto final al punto inicial
            blkRef.TransformBy(Matrix3d.Displacement(new Vector3d(offset.X, offset.Y, 0)));
            blockRecord.Draw(tr, blkRef);
        }