Example #1
0
        /// <summary>
        /// These are 'special cases' where there is a border that is usually not part of ESI's standard
        /// and a different parameters are set.
        /// Grabs these atypical parameters from a text file on the network
        /// </summary>
        /// <param name="BorderBlockName"></param>
        /// <returns></returns>
        public BorderStruct OtherDataConnection(string BorderBlockName)
        {
            BorderStruct myStruct = new BorderStruct();

            string textfile = MyPlugin.GetRoot() + @"DWGSetup\OtherBorders.txt";
            string line;

            using (StreamReader file = new StreamReader(textfile))
            {
                //goes through text file one line at a time to find a match
                while ((line = file.ReadLine()) != null)
                {
                    string[] strArray = line.Split(new string[] { "\t" }, StringSplitOptions.None);

                    if (strArray[0].ToString().ToUpper() == BorderBlockName.ToUpper())
                    {
                        //found our matching line.  Populate stuff
                        myStruct.BorderName = strArray[0].ToString();
                        myStruct.TitleBlock = strArray[1].ToString();
                        double.TryParse(strArray[2].ToString(), out myStruct.CenterX);
                        double.TryParse(strArray[3].ToString(), out myStruct.CenterY);
                        double.TryParse(strArray[4].ToString(), out myStruct.CenterZ);
                        double.TryParse(strArray[5].ToString(), out myStruct.Height);
                        double.TryParse(strArray[6].ToString(), out myStruct.Width);
                        myStruct.BorderSize = strArray[7].ToString();
                        break;
                    }
                    //if it gets here did not find a match
                }
                return(myStruct);
            }
        }
Example #2
0
        public static void InsertLayer()
        {
            Document            acDoc    = Application.DocumentManager.MdiActiveDocument;
            PromptStringOptions pStrOpts = new PromptStringOptions("");

            //from the menu macro command gets the filename of the text file to use
            PromptResult pStrRes = acDoc.Editor.GetString(pStrOpts);

            //concatenates the full file path
            string FileName = MyPlugin.GetRoot() + @"CSV\" + pStrRes.StringResult;

            //gets each line in the text file and adds each line to an element in a string array
            string[] fileLines = SplitFileByLine(FileName);

            //parses each element in individual line to get the variables we need
            for (int index = 0; index < fileLines.Length; index++)
            {
                string[] items = fileLines[index].Trim().Split(',');
                if (items.Length > 1)
                {
                    string Name     = items[0];
                    short  Color    = short.Parse(items[1]);
                    string LineType = items[2];

                    //makes sure the linetype exists
                    GeneralMenu.LoadLinetype(LineType);

                    //creates the layer
                    GeneralMenu.CreateLayer(Name, Color, LineType, false);
                    acDoc.Editor.WriteMessage("\n " + Name + " Layer created");
                }
            }
        }
Example #3
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            string LogoPath = MyPlugin.GetRoot() + @"Blocks\Logos\" + SelectedBorderSize + @"\" + LogoListBox.SelectedItem;

            GeneralMenu.AttachAsOverlay(new Point3d(0, 0, 0), LogoPath);

            this.Close();
        }
Example #4
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            string CoverSheetPath = MyPlugin.GetRoot() + @"Blocks\Cover Sheet Logos\" + SelectedBorderSize + @"\" + CoverSheetlistBox.SelectedItem;

            GeneralMenu.InsertBlockRef(new Point3d(0, 0, 0), CoverSheetPath);

            this.Close();
        }
Example #5
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            BorderStruct myStruct;

            //need a special case if the 'Other' checkbox is selected
            if (SelectedBorderSize == "Other")
            {
                myStruct = OtherDataConnection(BorderSheetListBox.SelectedItem.ToString());
            }
            else
            {
                myStruct = StandardSelectedBorderSize(SelectedBorderSize);
            }
            string LogoPath       = MyPlugin.GetRoot() + @"Blocks\Logos\" + SelectedBorderSize + @"\" + LogoListBox.SelectedItem;
            string BorderPath     = MyPlugin.GetRoot() + @"DWGSetup\Border\" + SelectedBorderSize + @"\" + myStruct.BorderName;
            string TitleBlockPath = MyPlugin.GetRoot() + @"DWGSetup\TitleBlock\" + myStruct.TitleBlock;
            string CoverSheetPath = MyPlugin.GetRoot() + @"Blocks\Cover Sheet Logos\" + SelectedBorderSize + @"\" + CoverSheetlistBox.SelectedItem;


            //switches to paperspace
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;

            Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("TILEMODE", 0);
            acDoc.Editor.SwitchToPaperSpace();

            //inserts Border
            GeneralMenu.AttachAsOverlay(new Point3d(0, 0, 0), BorderPath);

            //inserts Title Block
            if (myStruct.TitleBlock != "null")
            {
                GeneralMenu.InsertBlockRef(new Point3d(0, 0, 0), TitleBlockPath);
            }

            //inserts Viewport
            Point3d VPCenter = new Point3d(myStruct.CenterX, myStruct.CenterY, myStruct.CenterZ);

            GeneralMenu.CreateViewport(VPCenter, myStruct.Height, myStruct.Width);

            //inserts Logo
            if ((string)LogoListBox.SelectedItem != "No Logo")
            {
                GeneralMenu.AttachAsOverlay(new Point3d(0, 0, 0), LogoPath);
            }

            //inserts CoverSheet
            if ((string)CoverSheetlistBox.SelectedItem != null)
            {
                GeneralMenu.InsertBlockRef(new Point3d(0, 0, 0), CoverSheetPath);
            }

            //change drawing setup
            GeneralMenu.ChangePlotSetting(myStruct.BorderSize);

            this.Close();
        }
Example #6
0
 private void CoverSheetlistBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (CoverSheetlistBox.SelectedIndex != -1)
     {
         string filepath = MyPlugin.GetRoot() + @"Blocks\Cover Sheet Logos\" + SelectedBorderSize + @"\" + CoverSheetlistBox.SelectedItem;
         GeneralMenu.AcadIconPreview(filepath, CoverSheetPictureBox);
     }
     else
     {
         CoverSheetPictureBox.Image = null;
         CoverSheetPictureBox.Invalidate();
     }
 }
Example #7
0
 private void LogoListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((string)LogoListBox.SelectedItem != "No Logo")
     {
         string filepath = MyPlugin.GetRoot() + @"Blocks\Logos\" + SelectedBorderSize + @"\" + LogoListBox.SelectedItem;
         GeneralMenu.AcadIconPreview(filepath, LogoPictureBox);
     }
     else
     {
         LogoPictureBox.Image = null;
         LogoPictureBox.Invalidate();
     }
 }
Example #8
0
        public void PopulateLogo()
        {
            string FileName;

            LogoListBox.Items.Clear();
            string[] files = Directory.GetFiles(MyPlugin.GetRoot() + @"Blocks\Logos\" + SelectedBorderSize);

            foreach (string file in files)
            {
                FileName = Path.GetFileName(file);

                //makes sure only dwg files are added to the list
                if (Path.GetExtension(file) == ".dwg")
                {
                    LogoListBox.Items.Add(FileName);
                }
            }
            LogoListBox.SetSelected(0, true);
        }
Example #9
0
        public void INSBLK()
        {
            Document            acDoc    = Application.DocumentManager.MdiActiveDocument;
            PromptStringOptions pStrOpts = new PromptStringOptions("");

            //getting string result from menu macro
            //this gets the relative file name and path from the root
            // replaced @ with \ for folder structure because you can't put a \ in an AutoCAD menu macro string
            PromptResult pStrRes  = acDoc.Editor.GetString(pStrOpts);
            string       filepath = MyPlugin.GetRoot() + @"blocks\" + pStrRes.StringResult.Replace('@', '\\');

            //gets another string result from menu macro
            //this one tells what layer the block will be placed on
            pStrRes = acDoc.Editor.GetString(pStrOpts);
            string LayerName = pStrRes.StringResult;

            //runs the Jig so the user can insert the block
            Commands.BlockJigCmd(filepath, LayerName, true);
        }
Example #10
0
        public void VALVEBREAK()
        {
            Document            acDoc    = Application.DocumentManager.MdiActiveDocument;
            PromptStringOptions pStrOpts = new PromptStringOptions("");

            //getting string result from menu macro
            //this gets the relative file name and path from the root
            // replaced @ with \ for folder structure because you can't put a \ in an AutoCAD menu macro string
            PromptResult pStrRes  = acDoc.Editor.GetString(pStrOpts);
            string       filepath = MyPlugin.GetRoot() + @"blocks\" + pStrRes.StringResult.Replace('@', '\\');

            //another string result from the menu macro
            //this one will determine what layer the block will be inserted on
            pStrRes = acDoc.Editor.GetString(pStrOpts);
            string LayerName = pStrRes.StringResult;

            //checks to ensure the layer that the block is to be inserted on exists
            GeneralMenu.CreateLayer(LayerName, 7, "Continuous", false);

            InsertValveBlock.dostuff(filepath);
        }
Example #11
0
        private void LogoListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string filepath = MyPlugin.GetRoot() + @"Blocks\Logos\" + SelectedBorderSize + @"\" + LogoListBox.SelectedItem;

            GeneralMenu.AcadIconPreview(filepath, LogoPictureBox);
        }
Example #12
0
        public static void InsertColumnBubble()
        {
            //gets the current layer in the drawing so it can change back to it when we are done.
            //ObjectId CurrentLayer = HostApplicationServices.WorkingDatabase.Clayer;

            //gets the current document
            Document acDoc = Application.DocumentManager.MdiActiveDocument;

            //turns ortho mode on
            acDoc.Database.Orthomode = true;

            //prompts user for the initial insertion point of the block
            PromptPointOptions pto    = new PromptPointOptions("Insertion Point");
            PromptPointResult  pPtRes = acDoc.Editor.GetPoint(pto);

            //creates point3d from user input
            Point3d pt1 = new Point3d(pPtRes.Value.X, pPtRes.Value.Y, pPtRes.Value.Z);

            //gets second point from user that will determine where to place the block
            PromptPointOptions pto2 = new PromptPointOptions("Select Orientation");

            //we already have the base point from our first input, only need the second
            pto2.UseBasePoint = true;
            pto2.BasePoint    = pt1;


            PromptPointResult pPtRes2 = acDoc.Editor.GetPoint(pto2);
            Point3d           pt2     = new Point3d(pPtRes2.Value.X, pPtRes2.Value.Y, pPtRes2.Value.Z);

            //get the angle of the two points
            double angleA = pt1.GetVectorTo(pt2).AngleOnPlane(new Plane(new Point3d(0, 0, 0), new Vector3d(0, 0, 1)));

            //new point for our final insertion point
            Point3d Final = pt1;

            //depending on the angle displaces the final point accordingly
            if (angleA == 0)
            {
                Final = new Point3d(pt1.X + .1875, pt1.Y, pt1.Z);
            }

            if (angleA == 1.5707963267948966)
            {
                Final = new Point3d(pt1.X, pt1.Y + .1875, 0);
            }

            if (angleA == 3.1415926535897931)
            {
                Final = new Point3d(pt1.X - .1875, pt1.Y, pt1.Z);
            }

            if (angleA == 4.71238898038469)
            {
                Final = new Point3d(pt1.X, pt1.Y - .1875, 0);
            }


            //calls to insert block based on user input
            GeneralMenu.InsertBlockRef(Final, MyPlugin.GetRoot() + @"\Blocks\General\col-bubb.dwg", "col-bubb", 32, "Continuous");

            //turns ortho mode back off
            acDoc.Database.Orthomode = false;
            //acDoc.Database.Clayer = CurrentLayer;
        }