Try avoid selecting the objects using SelectByID2 - as you have noted it is view dependent. Use direct selection methods like ISketchSegment::Select4 instead.
Hello Artem, thanks for your reply. I now realise why my whole script reatcts in a wierd mannr.
Here is the reason why I am trying to use SelectById2 rather than Select4. I am trying to trim between a line which is a last segment created in the sketch and anther line which is created newly. Since SelectByID2 helps to choose the sides which i want the end trim result to be I use this approach rather than select4. Below shown is the piece of the code I have for the trim. The first SelectByID helps me to select the segement which is alreayd there in the sketch and the second it selects the line which I have just created. Is there a way I could use Select4 and still determine the side to be trimmed. Could you please suggest me an alternative solution if this approach is not an optimum one.
Set vsklines_1 = mymodel.SketchManager.CreateLine((Xend / 39.37), (Ymin_end / 39.37), 0, (Xend / 39.37), (Yend / 39.37), 0)
boolstatus = mymodel.Extension.SelectByID2("", "SKETCHSEGMENT", (X_midseg), (Y_midseg), 0, True, 0, Nothing, 0)
boolstatus = mymodel.Extension.SelectByID2("", "SKETCHSEGMENT", (X_midline2), ((Y_midline2)), 0, True, 0, Nothing, 0)
boolstatus = mymodel.SketchManager.SketchTrim(1, 0, 0, 0)
Thanks & Regards,
The second argument of SketchSegment::Select4 is a ISelectData interface which allows passing the additional data for selection. When you are doing trim the side is determined by the selection point.
You can get the selection data interface like this: SelectionMgr::CreateSelectData->ISelectData and specify the selection point through the following properties: ISelectData::X, ISelectData::Y, ISelectData::Z
Thanks you Artem, it worked fine as you said.