Select Object in Draft

Phenom
Phenom

From a button on a Form, I am trying to select a circle in Draft using objCircle.Select() and expecting it to get selected so user can proceed with doing some operation on the selected circle, like change color from the Command Bar which again I expect should now be 'active' and displaying properties for the circle.

This doesn't seem to happen. The circle does not get selected.

Is this the right function to use for what is sought ?

Are there any further calls or settings which would select the circle ?

I tried oApp.ActiveWindow.Update but it was not helpful.

Any insight is highly appreciated.

 

~Tushar

 

[EDIT]: The circle in question was created just a line earlier so my code looks like:

 

objCircle = objDoc.ActiveSheet.Circles2d.AddByCenterRadius(dCenX, dCenY, dRad)

objCircle.Select()

 

5 REPLIES

Re: Select Object in Draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hello Tushar,

 

you have to create a HighlightSet object via the Document.HighlightSets.Add method. Then add your object to the created HighlightSet object by using its AddItem method.

 

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Select Object in Draft

Phenom
Phenom

Thanks Wolfgang for the update.

I tried using HighlightSet but it won't actually 'select' nor the Command Bar display the properties of the circle like Diameter, etc. which appears when selected manually.

 

I also tried objCircle.Select() followed by objHighlightSet.AddSelected()

but it seems that the circle is 'not selected' in the first place.

If it does, it should highlight automatically in the default select color.

 

~Tushar

 

Re: Select Object in Draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Tushar,

 

sorry, you have to add the circle object to the SelectSet object also.

 

This demo code works for me. The circle gets highlighted, selected and the user sees the dialog to edit the circle's parameters.

 

...
var dftDoc = (SolidEdgeDraft.DraftDocument)seApp.ActiveDocument;
var selSet = dftDoc.SelectSet;
var highSet = dftDoc.HighlightSets.Add();

var circle2d = dftDoc.ActiveSheet.Circles2d.Item(1);

selSet.Add(circle2d);
highSet.AddItem(circle2d);
...
Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Select Object in Draft

Phenom
Phenom

Awesome. Works exactly as desired.

My program where this function was needed uses selection sets extensively but never thought it would be the SelectSet itself that will help. Highlighting happens automatically though.

  

Thanks a lot Wolfgang !

  

Tushar Suradkar

Re: Select Object in Draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hello Tushar,

 

you're right, highlighting happens (now ST8?) automatically as soon as adding an object to the SelectSet. As far as i remember there were times it didn't happen automatically Smiley Frustrated

Kind regards,
Wolfgang Kunert - www.wksyspro.de