Pick a drawing line, after clicking the button in the add-ins

Hubert_Los
Advocate

Pick a drawing line, after clicking the button in the add-ins

Hubert_Los
Advocate
Advocate

Hello,

 

I created an add-in and added it to the ribbon. I would like to select a drawing line when I click the button. The program waits for the line to be selected, but I can't select anything. The program crashes and stops in the code.

        private void btnPick_Click(object sender, EventArgs e)
        {


            DrawingCurveSegment pickedLine = (DrawingCurveSegment)m_inventorApp.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "pick line"); //here the program stops
        .
        .
        .
        }


The same code works if I run it in visual studio and use the(then windows form is independent of Inventor):

 

m_inventorApp = MarshalCore.GetActiveObject("Inventor.Application") as Inventor.Application;



In the picture shows that the add-in can read the names of open drawings, so it works. Everything except the line selection.

I cannot perform any action in Inventor until I close the add-in.
I tried to hide windows form, but it is not enough.

I suspect that I need to deactivate windows form during line selection, however I have no idea how I can do that.

Do you have any advice on how to do this?

 

Hubert_Los_0-1720166835726.png

Screen after click btnPick (The program crashed. There is no "pick line" message visible, which is in the code)

Hubert_Los_1-1720167093255.png

 

0 Likes
Reply
Accepted solutions (1)
265 Views
1 Reply
Reply (1)

Hubert_Los
Advocate
Advocate
Accepted solution

I used .Show instead of .ShowDialog and now it works.

        protected override void ButtonDefinition_OnExecute(NameValueMap context)
        {
            var frm = new InventorFormDialog(m_inventorApp);
            frm.Show();
        }




0 Likes