Reply

Bullet textbox on draft

Hi,

 

I'm trying to insert a textbox (which containts a header and some items).

After inserting I want to "select" the items (not the header!) and add a bullet to them.

This is what I got:

 Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objDraftDocument As SolidEdgeDraft.DraftDocument = Nothing
        Dim objSheet As SolidEdgeDraft.Sheet = Nothing
        Dim objTextBoxs As SolidEdgeFrameworkSupport.TextBoxes = Nothing
        Dim objTextBox As SolidEdgeFrameworkSupport.TextBox = Nothing
        Dim objTextEdit As SolidEdgeFrameworkSupport.TextEdit = Nothing

        Try
            OleMessageFilter.Register()
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")
            objDraftDocument = objApplication.ActiveDocument
            objSheet = objDraftDocument.ActiveSheet
            objTextBoxs = objSheet.TextBoxes
            objTextBox = objTextBoxs.Add(x1:=0.1, y1:=0.3, z1:=0)
            objTextBox.Text = "Header" & vbCrLf & "Item 1" & vbCrLf & "Item 2" & vbCrLf & "Item 3"
            objTextEdit = objTextBox.Edit
            objTextEdit.SetSelect(1, 3, SolidEdgeFrameworkSupport.TextSelectConstants.seTextSelectParagraph)
            objTextEdit.SetBulletList(TextBulletTypeConstants.igDash)
            objTextEdit.Bullet = True
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            OleMessageFilter.Unregister()
        End Try

The text is being inserted but the bullets aren't added to the items.

Maarten Elings | Mechanical Engineer
1 REPLY

Re: Bullet textbox on draft

This is closer but I can't seem to get the dashes to take. Note that SetSelect() needs seTextSelectRange to select the range you want.

 

[STAThread]
static void Main(string[] args)
{
    SolidEdgeFramework.Application application = null;

    try
    {
        // Register with OLE to handle concurrency issues on the current thread.
        OleMessageFilter.Register();

        // Connect to or start Solid Edge.
        application = SolidEdgeCommunity.SolidEdgeUtils.Connect();

        application.DisplayAlerts = false;

        var textBox = (SolidEdgeFrameworkSupport.TextBox)application.ActiveSelectSet.Item(1);
        var textEdit = textBox.Edit;

        var header = "Header" + Environment.NewLine;
        var body = "Item 1" + Environment.NewLine + "Item 2" + Environment.NewLine + "Item 3" + Environment.NewLine;
        var headerLength = header.Length;
        var bodyLength = body.Length + 10;

        textBox.Text = header + body;
        textEdit.SetSelect(headerLength, bodyLength, SolidEdgeFrameworkSupport.TextSelectConstants.seTextSelectRange);
        textEdit.SetBulletList(SolidEdgeFrameworkSupport.TextBulletTypeConstants.igDash);
    }
    catch (System.Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
    finally
    {
        OleMessageFilter.Unregister();
    }
}
Jason Newell
Applications Architect
www.jasonnewell.net