Exemplo n.º 1
0
            public PlineJig(Matrix3d ucs)
                : base(new Polyline())
            {
                // Create a point collection to store our vertices
                m_pts = new Point3dCollection();

                // Create a temporary plane, to help with calcs
                Point3d origin = new Point3d(0, 0, 0);

                Vector3d normal = new Vector3d(0, 0, 1);

                normal  = normal.TransformBy(ucs);
                m_plane = new Plane(origin, normal);

                // Create polyline, set defaults, add dummy vertex
                Polyline pline = Entity as Polyline;

                pline.SetDatabaseDefaults();

                pline.Normal = normal;

                //makes sure the layer exists then switches over to the layer
                GeneralMenu.CreateLayer("Match", 134, "ByLayer", false);
                pline.Layer = "Match";

                //makes sure the linetype exists then assigns the linetype
                GeneralMenu.LoadLinetype("PHANTOM");
                pline.Linetype = "PHANTOM";

                pline.AddVertexAt(0, new Point2d(0, 0), 0, .0625, .0625);

                //Application.DocumentManager.MdiActiveDocument.Database.Orthomode = true;
            }
Exemplo n.º 2
0
        public static void RevisionCloudCommand()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            //ensures the REV layer exists in the drawing, if not adds it
            GeneralMenu.CreateLayer("REV", 91, "Continuous", true);

            using (Transaction acTrans = db.TransactionManager.StartTransaction())
            {
                //finds and makes the REV layer the current layer for the drawing
                LayerTable acLyrTbl = acTrans.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
                db.Clayer = acLyrTbl["REV"];

                acTrans.Commit();
            }

            //user inserts the triangle thingy
            Commands.BlockJigCmd(revtri, true);

            //get the current revision number from the title block
            string value = GetRevLetter();

            //updates the attribute for ALL triangle block references in the drawing
            if (value != null)
            {
                UpdateAttributesInRevBlock("REVTRI.DWG", "LEVEL", value);
            }
            //user inserts the revision cloud
            doc.SendStringToExecute("REVCLOUD ", true, false, true);
        }
Exemplo n.º 3
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");
                }
            }
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
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();
     }
 }
Exemplo n.º 8
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();
     }
 }
Exemplo n.º 9
0
            public MLeaderJig(string contents)
                : base(new MLeader())
            {
                // Store the string passed in
                m_contents = contents;

                // Create a point collection to store our vertices
                m_pts = new Point3dCollection();

                // Create mleader and set defaults
                MLeader ml = Entity as MLeader;

                ml.SetDatabaseDefaults();
                ml.Layer = "DIM";

                // Set up the MText contents
                ml.ContentType = ContentType.MTextContent;

                MText mt = new MText();

                mt.SetDatabaseDefaults();
                mt.Contents = m_contents;

                mt.TextStyleId = GeneralMenu.GetTextstyleId("ESI-STD");

                ml.MText     = mt;
                ml.TextColor = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 32);

                //ml.TextAlignmentType = TextAlignmentType.LeftAlignment;
                //ml.TextAttachmentType = TextAttachmentType.AttachmentTopOfTop;

                //// Set the frame and landing properties
                //ml.EnableDogleg = true;
                //ml.EnableFrameText = true;
                //ml.EnableLanding = true;

                ml.SetTextAttachmentType(TextAttachmentType.AttachmentMiddleOfTop, LeaderDirectionType.LeftLeader);
                ml.SetTextAttachmentType(TextAttachmentType.AttachmentMiddleOfBottom, LeaderDirectionType.RightLeader);


                // Reduce the standard landing gap
                ml.LandingGap = .125;

                // Add a leader, but not a leader line (for now)
                m_leaderIndex     = ml.AddLeader();
                m_leaderLineIndex = -1;
            }
Exemplo n.º 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);
        }
Exemplo n.º 11
0
        private void LogoListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string filepath = MyPlugin.GetRoot() + @"Blocks\Logos\" + SelectedBorderSize + @"\" + LogoListBox.SelectedItem;

            GeneralMenu.AcadIconPreview(filepath, LogoPictureBox);
        }
Exemplo n.º 12
0
        public void MyPolyJig()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            Editor ed = doc.Editor;
            // Get the current UCS, to pass to the Jig
            Matrix3d ucs = ed.CurrentUserCoordinateSystem;

            //ensures that the layer the object will be created on exists, if it doesn't creates it
            GeneralMenu.CreateLayer("DIM", 1, "Continuous", true);

            // Create our Jig object
            PlineJig jig = new PlineJig(ucs);

            // Loop to set the vertices directly on the polyline
            bool bSuccess = true;

            for (int i = 0; i < 2; i++)
            {
                PromptResult res = ed.Drag(jig);
                bSuccess = (res.Status == PromptStatus.OK);

                // A new point was added
                if (bSuccess)
                {
                    jig.AddLatestVertex();
                }
            }
            jig.RemoveLastVertex();


            Ellipse el = InsertElipse();

            //formula for calculating a polar point based on a base point, an angle, and the distance
            Point3d newpoint = new Point3d(el.Center.X + 0.04492187 * Math.Cos(angleA + 4.71238898), el.Center.Y + 0.04492187 * Math.Sin(angleA + 4.71238898), 0);

            jig.ReplaceOrigin(newpoint);

            MText tx = addText();


            // If the jig completed successfully, add the polyline
            // Append entity
            Database db = doc.Database;

            Transaction tr = db.TransactionManager.StartTransaction();



            using (tr)
            {
                BlockTable       bt  = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false);
                BlockTableRecord btr = ((BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite));
                btr.AppendEntity(jig.GetEntity());
                btr.AppendEntity(el);
                btr.AppendEntity(tx);
                tr.AddNewlyCreatedDBObject(jig.GetEntity(), true);
                tr.AddNewlyCreatedDBObject(el, true);
                tr.AddNewlyCreatedDBObject(tx, true);
                tr.Commit();
            }
        }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
        static public void BlockJigCmd(string strSourceBlockPath, string LayerName, bool displayAttEdit)
        {
            //same stuff
            Document         doc = Application.DocumentManager.MdiActiveDocument;
            Database         db  = doc.Database;
            Editor           ed  = doc.Editor;
            BlockTableRecord btr;

            Transaction tr = doc.TransactionManager.StartTransaction();

            using (tr)
            {
                string strSourceBlockName = Path.GetFileName(strSourceBlockPath);

                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                //if block already exists in drawing retrieve it, if not create if from external drawing
                if (bt.Has(strSourceBlockName))
                {
                    ObjectId id = bt[strSourceBlockName];
                    btr = (BlockTableRecord)tr.GetObject(id, OpenMode.ForRead, true, true);
                }
                else
                {
                    BlockTableRecord btrSource = GeneralMenu.GetBlock(strSourceBlockName, strSourceBlockPath);
                    if (btrSource == null)
                    {
                        return;
                    }
                    btr = (BlockTableRecord)tr.GetObject(btrSource.ObjectId, OpenMode.ForRead, true, true);
                }

                BlockTableRecord space = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                // Block needs to be inserted to current space before
                // being able to append attribute to it
                BlockReference br = new BlockReference(new Point3d(), btr.ObjectId);

                GeneralMenu.CreateLayer(LayerName, false);
                br.Layer = LayerName;

                space.AppendEntity(br);
                tr.AddNewlyCreatedDBObject(br, true);

                Dictionary <ObjectId, AttInfo> attInfo = new Dictionary <ObjectId, AttInfo>();

                if (btr.HasAttributeDefinitions)
                {
                    foreach (ObjectId id in btr)
                    {
                        DBObject            obj = tr.GetObject(id, OpenMode.ForRead);
                        AttributeDefinition ad  = obj as AttributeDefinition;

                        if (ad != null && !ad.Constant)
                        {
                            AttributeReference ar = new AttributeReference();
                            ar.SetAttributeFromBlock(ad, br.BlockTransform);
                            ar.Position = ad.Position.TransformBy(br.BlockTransform);

                            if (ad.Justify != AttachmentPoint.BaseLeft)
                            {
                                ar.AlignmentPoint = ad.AlignmentPoint.TransformBy(br.BlockTransform);
                            }

                            if (ar.IsMTextAttribute)
                            {
                                ar.UpdateMTextAttribute();
                            }

                            ar.TextString = ad.TextString;
                            ObjectId arId = br.AttributeCollection.AppendAttribute(ar);
                            tr.AddNewlyCreatedDBObject(ar, true);

                            // Initialize our dictionary with the ObjectId of
                            // the attribute reference + attribute definition info

                            attInfo.Add(arId, new AttInfo(ad.Position, ad.AlignmentPoint, ad.Justify != AttachmentPoint.BaseLeft));
                        }
                    }
                }

                // Run the jig
                BlockJig myJig = new BlockJig(tr, br, attInfo);

                if (myJig.Run() != PromptStatus.OK)
                {
                    return;
                }
                if (btr.HasAttributeDefinitions && displayAttEdit)
                {
                    doc.SendStringToExecute("_.EATTEDIT l ", true, false, true);
                    //CommandLine.Command("_.EATTEDIT", br.ObjectId);
                }
                // Commit changes if user accepted, otherwise discard
                tr.Commit();
            }
        }