/// <summary> /// insert a sketched symbol by the definition above /// </summary> /// <remarks></remarks> public void InsertSketchedSymbolOnSheet() { // Set a reference to the drawing document. // This assumes a drawing document is active. DrawingDocument oDrawDoc = (DrawingDocument)_InvApplication.ActiveDocument; // Obtain a reference to the desired sketched symbol definition. SketchedSymbolDefinition oSketchedSymbolDef = default(SketchedSymbolDefinition); oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions["Circular Callout"]; Sheet oSheet = oDrawDoc.ActiveSheet; // This sketched symbol definition contains one prompted string input. An array // must be input that contains the strings for the prompted strings. string[] sPromptStrings = new string[1]; sPromptStrings[0] = "A"; TransientGeometry oTG = _InvApplication.TransientGeometry; // Add an instance of the sketched symbol definition to the sheet. // Rotate the instance by 45 degrees and scale by .75 when adding. // The symbol will be inserted at (0,0) on the sheet. Since the // start point of the line was marked as the insertion point, the // start point should end up at (0,0). SketchedSymbol oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oTG.CreatePoint2d(0, 0), (3.14159 / 4), 0.75, sPromptStrings); }
//creating a new sketched symbol definition object and // inserting it into the active sheet. // This sample consists of two subs. // The first demonstrates the creation of a sketched symbol definition and // the second inserts it into the active sheet. // To run the sample have a drawing document open and run the CreateSketchedSymbolDefinition Sub. // After this you can run the InsertSketchedSymbolOnSheet to insert the sketched symbol into the active sheet. // The insertion sub demonstrates the use of the insertion point in the symbol's definition while inserting the symbol. /// <summary> /// creating a new sketched symbol definition object ''' /// </summary> /// <remarks></remarks> public void CreateSketchedSymbolDefinition() { // Set a reference to the drawing document. // This assumes a drawing document is active. DrawingDocument oDrawDoc = (DrawingDocument)_InvApplication.ActiveDocument; // Create the new sketched symbol definition. SketchedSymbolDefinition oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Add("Circular Callout"); // Open the sketched symbol definition's sketch for edit. This is done by calling the Edit // method of the SketchedSymbolDefinition to obtain a DrawingSketch. This actually creates // a copy of the sketched symbol definition's and opens it for edit. DrawingSketch oSketch = null; oSketchedSymbolDef.Edit(out oSketch); TransientGeometry oTG = _InvApplication.TransientGeometry; // Use the functionality of the sketch to add sketched symbol graphics. SketchLine oSketchLine = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(0, 0), oTG.CreatePoint2d(20, 0)); SketchCircle oSketchCircle = oSketch.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(22, 0), 2); oSketch.GeometricConstraints.AddCoincident((SketchEntity)oSketchLine.EndSketchPoint, (SketchEntity)oSketchCircle); // Make the starting point of the sketch line the insertion point oSketchLine.StartSketchPoint.InsertionPoint = true; // Add a prompted text field at the center of the sketch circle. string sText = null; sText = "<Prompt>Enter text 1</Prompt>"; Inventor.TextBox oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(22, 0), sText); oTextBox.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextMiddle; oTextBox.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter; oSketchedSymbolDef.ExitEdit(true); }