Example #1
0
        static Cpblk()
        {
            var dynamicMethod = new DynamicMethod(string.Empty, typeof(void), new Type[] { typeof(IntPtr), typeof(IntPtr), typeof(int) });
            var ilGenerator   = dynamicMethod.GetILGenerator();

            //Emitting destination address
            ilGenerator.Emit(SRE.OpCodes.Ldarg_0);
            //Emitting source address
            ilGenerator.Emit(SRE.OpCodes.Ldarg_1);
            //Emitting length
            ilGenerator.Emit(SRE.OpCodes.Ldarg_2);
            ilGenerator.Emit(SRE.OpCodes.Cpblk);
            ilGenerator.Emit(SRE.OpCodes.Ret);
            _copy = (CopyBlock)dynamicMethod.CreateDelegate(typeof(CopyBlock));
        }
Example #2
0
 public TranslateBlock(CopyBlock source, string title, bool autoCopy)
 {
     InitializeComponent();
     _sourceBlock = source;
     Text         = title;
     if (autoCopy)
     {
         buttonCopySourceTextToClipboard_Click(null, null);
         buttonCopySourceTextToClipboard.Text = "Copy source text clipboard again";
         buttonCopySourceTextToClipboard.Font = new System.Drawing.Font(Font.FontFamily.Name, buttonCopySourceTextToClipboard.Font.Size, System.Drawing.FontStyle.Regular);
     }
     else
     {
         buttonCopySourceTextToClipboard.Text = "Copy source text clipboard";
         buttonCopySourceTextToClipboard.Font = new System.Drawing.Font(Font.FontFamily.Name, buttonCopySourceTextToClipboard.Font.Size, System.Drawing.FontStyle.Bold);
     }
 }
Example #3
0
        public void BlockSearch()
        {
            var    db = Application.DocumentManager.MdiActiveDocument.Database;
            var    blockDeserialize = new BlockDeserializer();
            string path             = @"E:\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder\Autocad PID blocks work in progress.dwg";
            // Copy blocks from sourcefile into opened file
            var copyBlock = new CopyBlock();

            #region btrNamesToCopy
            var eqType = new[] {
                "aeration diffuzer",
                "arrow",
                "alkalinity_chamber",
                "blower",
                "break",
                "chamber",
                "chamber circular",
                "chamber description",
                "channel",
                "channel gate",
                "channel2",
                "clarifier circular",
                "Clarifier Equipment",
                "clarifier longitudial",
                "collector",
                "controll tag e",
                "digester",
                "digester cap",
                "drum filter",
                "filter",
                "filter2",
                "Gas equipments",
                "gas flame",
                "gas holder",
                "grease_coll_chmbr",
                "heating",
                "instrumentairheaderarrow",
                "instrumentation tag",
                "leachet_coll_chmbr",
                "moister trap",
                "TWT",
                "ozone unit",
                //"PID-PS-FRAME",
                "pipe",
                "pipe2",
                "poli dosing",
                "pump",
                "mixer",
                "pr_cl_chmbr",
                "reactor",
                "RefALSewage",
                "RefALPoly",
                "RefALPotable",
                "RefALRecSludge",
                "RefARRecSludge",
                "RefALTransport",
                "RefARRawSludge",
                "RefARSewage",
                "RefARNaturalGas",
                "RefALRawSludge",
                "RefPIDEfluent",
                "RefPIDInfluent",
                "RefAL1AirToBiofilter",
                "RefAL1AirfromSludge",
                "RefAR1AirfromSludge",
                "RefAL2UtilityWater",
                "RefAR2UtilityWater",
                "RefAR3UtilityWater",
                "RefAL3UtilityWater",
                "RefAR4Leachate",
                "RefAL5Leachate",
                "RefAL6WasteSludge",
                "RefAR6WasteSludge",
                "RefAL7WasteAir",
                "RefAR7WasteAir",
                "RefAR10Sludge",
                "RefAR12Gas",
                "RefAR13Sludge",
                "RefAR14Water",
                "RefAL15Water",
                "RefAR16Water",
                "RefAL17Water",
                "RefAR18Water",
                "RefAL19Water",
                "RefAL22WasteSludge",
                "RefAR22WasteSludge",
                "RefAL23Leachate",
                "RefAR24UtilityWater",
                "RefAL25UtilityWater",
                "RefAR25UtilityWater",
                "RefAR26Leachate",
                "RefAL26Leachate",
                "sand trap",
                "screen",
                "screening press",
                "sst2_chmbr",
                "sst2Dig",
                "screening press",
                "sludge dewatering",
                "tank - vessel",
                "valve",
                "Vortex_grit_chamber",
                "Vortex_sand_chamber",
                "vortexEQ"
            };
            #endregion

            string[] btrNamesToCopy = eqType.Distinct().ToArray();

            copyBlock.CopyBlockTable(db, path, btr =>
            {
                System.Diagnostics.Debug.Print(btr.Name);
                return(btrNamesToCopy.Contains(btr.Name));
            });

            var defultLayers = new LayerCreator();
            defultLayers.Layers();

            var insertBlock = new InsertBlock(db);
            var filePath    = @"E:\Jszomor\source\repos\jszomorCAD\jCAD.PID_Builder\JsonPIDBuild.json";
            var jsonPID     = blockDeserialize.ReadJsonData(filePath);

            //var sBlockName = jsonPID.Blocks.Select(b => b.Misc.BlockName);
            var blockNames =
                from b in jsonPID.Blocks
                select b.Misc.BlockName;

            foreach (var blockName in btrNamesToCopy)
            {
                try
                {
                    insertBlock.PlaceBlocksByName(jsonPID, blockName);
                    //MoveToBottom.SendToBackBlock();
                }
                catch (ArgumentNullException)
                {
                    // ignore
                }
            }

            var    insertBlockTable = new BlockTableRead(db);
            string fileName         = "JsonPIDBuildCopy.json";
            insertBlockTable.ReadBtrForSeri(db, fileName);
            //var blockDeserialize = new BlockDeserialize();
            //var eqType = blockDeserialize.BlockSearch("Name");

            //System.Diagnostics.Debug.Print($"BlockName: {eqType}");
        }
Example #4
0
        public void ListBlocks()
        {
            var db = Application.DocumentManager.MdiActiveDocument.Database;

            // Copy blocks from sourcefile into opened file
            var copyBlockTable = new CopyBlock();
            var btrNamesToCopy = new[] { "pump", "valve", "chamber", "instrumentation tag", "channel gate", "pipe", "pipe2", "channel", "channel2" };

            copyBlockTable.CopyBlockTable(db, path, btr =>
            {
                System.Diagnostics.Debug.Print(btr.Name);
                return(btrNamesToCopy.Contains(btr.Name));
            });


            //var sizeProperty = new PositionProperty();
            //"\nEnter number of equipment:"
            //var pio = new PromptIntegerOptions("\nEnter number of equipment:") { DefaultValue = 5 };
            //var number = Application.DocumentManager.MdiActiveDocument.Editor.GetInteger(pio);
            //var intNumber = Convert.ToInt32(number.Value);

            //"\nEnter distance of equipment:"
            //var dio = new PromptIntegerOptions("\nEnter distance of equipment:") { DefaultValue = 20 };
            //var distance = Application.DocumentManager.MdiActiveDocument.Editor.GetInteger(dio);
            //var intDistance = Convert.ToInt32(distance.Value);

            //"\nEnter index of equipment:"
            //var eio = new PromptIntegerOptions("\nEnter index of equipment:") { DefaultValue = 22 };
            //var eqIndex = Application.DocumentManager.MdiActiveDocument.Editor.GetInteger(eio);
            //var promptEqIndex = Convert.ToInt16(eqIndex.Value);

            var  selectorProperty = new SelectorProperty();
            long numbers          = JsonProcessClass.JsonProcessValue("number_of_eqPump");
            long indexOfEqPump    = JsonClass.JsonEquipmentValue("Equalization Tank Pump");
            var  promptEqIndex    = Convert.ToInt16(indexOfEqPump);

            var eqt = new EqualizationTank(numberOfPumps: Convert.ToInt32(EquipmentSelector.EqPumpNumberSelect(selectorProperty)), distanceOfPump: 20, eqIndex: promptEqIndex);

            //var InsBlock = new BlockMapping();
            #region old code
            //var blocks = new[]
            //{
            //  new InsertBlockBase(numberOfItem: 1,
            //    blockName: "chamber",
            //    layerName: "unit",
            //    x: 0,
            //    y: 0,
            //    hostName: "Equalization Tank")
            //  {
            //    ActionToExecuteOnDynProp = new Action<DynamicBlockReferenceProperty>[]
            //    {
            //      dbrProp =>
            //      {
            //        if (dbrProp.PropertyName == "Visibility")
            //          dbrProp.Value = "no channel";
            //      }
            //    },
            //    ActionToExecuteOnAttRef = new Action<AttributeReference>[]
            //    {
            //      ar =>
            //      {
            //        //text for EQ tank - Attributes
            //        if (ar.Tag == "NAME1")
            //          ar.TextString = "EQUALIZATION";
            //        if (ar.Tag == "NAME2")
            //          ar.TextString = "TANK";
            //      }
            //    },
            //    ActionToExecuteOnDynPropAfter = new Action<DynamicBlockReferenceProperty>[]
            //    {
            //      dbrProp =>
            //      {
            //        //setup chamber width
            //        if (dbrProp.PropertyName == "Distance")
            //          dbrProp.Value = 5.0d * 20 + 50; //last value is the free space for other items
            //        //text position for chamber
            //        if (dbrProp.PropertyName == "Position X")
            //          dbrProp.Value = (5 * 20 + 50) / 2.0d; //place text middle of chamber horizontaly
            //      }
            //    },
            //  },
            //};
            #endregion

            var layers = new[]
            {
                new LayerData("unit", Color.FromRgb(255, 0, 0), 0.25, false)
            };

            var layerCreator = new LayerCreator();
            layerCreator.LayerCreatorMethod(layers);

            DrawBlocks(db, eqt.Blocks);
            //DrawBlocks(db, InsBlock.Blocks);

            #region oldcode
            ////short shortCheckValveIndex = 2;
            //PositionProperty.NumberOfPump = number.Value;
            //PositionProperty.DistanceOfPump = distance.Value;

            //var ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //var aw = new AutoCadWrapper();


            ////copyBlockTable.CopyBlockTableMethod(db, path, btr => true);
            //sizeProperty.X = 50;

            //// Call a transaction to create layer

            ////layerCreator.LayerCreatorMethod("equipment", Color.FromRgb(0, 0, 255), 0.5);

            ////layerCreator.LayerCreatorMethod("unit", Color.FromRgb(0, 0, 255), 0.5);

            //// Start transaction to write equipment

            //var insertEqTAnkPump = new InsertBlockBase(PositionProperty.NumberOfPump,               // number of item
            //  PositionProperty.DistanceOfPump,             // disctance of item
            //  "pump",                                      //block name
            //  "equipment",                                 //layer name
            //  "Centrifugal Pump",                          //dynamic property type
            //  shortEqIndex,                                //visibility of equipment ()
            //  sizeProperty.X,                              //X
            //  10,                                          //Y
            //  "Equalization Tank",                         //Host name
            //  0);                                          //pipe length
            //insertBlockTable.InsertBlockTableMethod(db, insertEqTAnkPump);
            ////
            //var insertEqTAnk = new InsertBlockBase(
            //  1,                                          // number of item
            //  0,                                          // disctance of item
            //  "chamber",                                  //block name
            //  "unit",                                     //layer name
            //  "Visibility",                               //dynamic property type
            //  "no channel",                               //visibility of equipment
            //  0,                                          //X
            //  0,                                          //Y
            //  "Equalization Tank",                        //Host name
            //  0);                                         //pipe length
            //insertBlockTable.InsertBlockTableMethod(db, insertEqTAnk);
            ////
            //var insertCheckValve = new InsertBlockBase(
            //  PositionProperty.NumberOfPump,              // number of item
            //  PositionProperty.DistanceOfPump,            // disctance of item
            //  "valve",                                    //block name
            //  "valve",                                    //layer name
            //  "Block Table1",                             //dynamic property type
            //  (short)5,                                          //visibility of equipment (check valve)
            //  sizeProperty.X,                             //X
            //  25,                                         //Y
            //  "Equalization Tank",                        //Host name
            //  0);                                         //pipe length
            //insertBlockTable.InsertBlockTableMethod(db, insertCheckValve);
            ////
            //var insertGateValve = new InsertBlockBase(
            //  PositionProperty.NumberOfPump,            // number of item
            //  PositionProperty.DistanceOfPump,          // disctance of item
            //  "valve",                                  //block name
            //  "valve",                                  //layer name
            //  "Block Table1",                           //dynamic property type
            //  (short)0,                                        //visibility of equipment (gate valve)
            //  sizeProperty.X,                           //X
            //  40,                                       //Y
            //  "Equalization Tank",                      //Host name
            //  0);                                       //pipe length
            //insertBlockTable.InsertBlockTableMethod(db, insertGateValve);
            ////
            //var insertLIT = new InsertBlockBase(
            //  1,                                        // number of item
            //  0,                                        // disctance of item
            //  "instrumentation tag",                    //block name
            //  "instrumentation",                        //layer name
            //  "Block Table1",                           //dynamic property type
            //  (short)7,                                        //visibility of equipment (LIT)
            //  PositionProperty.NumberOfPump
            //  * PositionProperty.DistanceOfPump + 50,   //X
            //  10,                                       //Y
            //  "Equalization Tank",                      //Host name
            //  0);                                       //pipe length
            ////
            //var insertFIT = new InsertBlockBase(
            //  1,                                        // number of item
            //  0,                                        // disctance of item
            //  "instrumentation tag",                    //block name
            //  "instrumentation",                        //layer name
            //  "Block Table1",                           //dynamic property type
            //  (short)11,                                       //visibility of equipment (FIT)
            //  PositionProperty.NumberOfPump
            //  * PositionProperty.DistanceOfPump + 50,   //X
            //  50,                                       //Y
            // "Equalization Tank",                       //Host name
            //  0);                                       //pipe length
            ////
            //var insertJetPump = new InsertBlockBase(
            //  1,                                        // number of item
            //  0,                                        // disctance of item
            //  "pump",                                   //block name
            //  "equipment",                              //layer name
            //  "Centrifugal Pump",                       //dynamic property type
            //  (short)17,                                       //visibility of jet pump
            //  20,                                       //X
            //  10,                                       //Y
            //  "Equalization Tank",                      //Host name
            //  0);                                       //pipe length
            ////
            //var insertChannelGateSTB = new InsertBlockBase(
            //  1,                                        // number of item
            //  0,                                        // disctance of item
            //  "channel gate",                           //block name
            //  "equipment",                              //layer name
            //  "Block Table1",                           //dynamic property type
            //  (short)23,                                       //visibility of item (Channel gate (Equalization Tank))
            //  -10.5,                                    //X
            //  6,                                        //Y
            // "Equalization Tank",                       //Host name
            //  0);                                       //pipe length
            ////

            //var insertChannelGateDTY = new InsertBlockBase(
            //  1,                                         // number of item
            //  0,                                         // disctance of item
            //  "channel gate",                            //block name
            //  "equipment",                               //layer name
            //  "Block Table1",                            //dynamic property type
            //  (short)23,                                        //visibility of item (Channel gate (Equalization Tank))
            //  -10.5,                                     //X
            //  -24,                                       //Y
            //  "Equalization Tank",                       //Host name
            //  0);                                        //pipe length

            //var insertPipe1 = new InsertBlockBase(
            //  PositionProperty.NumberOfPump,             // number of item
            //  PositionProperty.DistanceOfPump,           // disctance of item
            //  "pipe",                                    //block name
            //  "sewer",                                   //layer name
            //  "Visibility1",                             //dynamic property type
            //  "sewer",                                   //visibility of item (sewer pipe)
            //  50,                                        //X
            //  14,                                        //Y
            //  "Equalization Tank",                       //Host name
            //  36);

            //var blocks = new[] {
            //  insertPipe1, insertChannelGateDTY, insertChannelGateSTB
            //};

            #endregion
        }