News:

Be sure your post is relevant to the current discussion.  Create a new topic within the appropriate board if you are unsure.

Main Menu

selecting an existing object in TC

Started by nikkipollard, August 24, 2020, 04:02:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nikkipollard

 Using Vb.net and visualstudio community version 2019
I am tryng to select a polyline to get information from the polyline.
this code seems to work but , the prompt below the inspector bar asks for the first corner of a view object.
I Ignore that, because it does work , but I am sure that I am using the wrong selection tool.


Dim viw As IMSIGX.View = TCdraw.ActiveView
        Dim Pres As IMSIGX.PickResult
        Dim Pent As IMSIGX.PickEntry
        Dim xClick#, yClick#
        MsgBox("select first polyline,then second polyline")
        viw.GetMouseClick(xClick, yClick)
        Pres = viw.PickPoint(xClick, yClick)
        Pent = Pres.Item(0)
        Pent.Graphic.Select()
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Andy H

Not something I've ever used. What I've done in the past is required objects to be selected before running any code. So I just needed to code a check to see if anything is selected.

Your code certainly works.  The text below the inspection bar, maybe just some generic text because you are referencing the view object.

I'm sure you are aware, (but in case not). You would need to add some code to check if anything has been clicked on. If one just runs the code and clicks away from an object, It pauses the debug in VB studio with an error. because there is no objects within the PickResult. So pres.Item(0) would be a null value.

I'm sure you have guessed by now. very few people post in the SDK section.   Hopefully ibruethsch will visit sometime.  He is good with the SDK.

nikkipollard

#2
Thanks Andy , I see that is how how most of the examples work. but I wanted to select 2 polylines in a specific order,
as each set of vertices would have a different function.
The error handling is something I am learning the hard way. The example in the chm tests to see if the selected item is a "circle."
I tried the same method - with a "polyline" instead of circle. but TC didn't accept that.
So I used a message box  to see what graphic type the "polyline" was -  it returned "graphic".  Which isn't specific enough.
So I put the error handling on hold for now.

I know that the Sdk forum is very quiet. But I also know that programmers like things to be done a specific way.
So I ask questions and when I don't get an answer I do my own thing. - Which is like reinventing the wheel. and possibly quite dangerous.

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Andy H

I'll have a think about the polyline thing.

But a simple routine for the error checking of a blank area instead of an object, may be as follows.  The last bit of the MsbBox MsgBoxStyle.SystemModal, "On Top" is to try to force the box to the front of the screen.  Because, as the Tc window would have been the last thing clicked it would have focus. So a simple MsgBox would appear behind the TC window.

If Pres.Count > 0 Then
            Pent = Pres.Item(0)
            Pent.Graphic.Select()
Else
            MsgBox("No objects seleted", MsgBoxStyle.SystemModal, "On Top")

End If

Andy H

Nope. No luck.

One could use the TypeByValue to get the numeric code. But.  The problem is, that code 11 applies to any line with 2 or more vertex (even double lines), Even the name polyline is a generic name. because a rectangle is a polyline as far as TC is concerned. 

There is an extended property called M_ObjectType Value, which can show the object name (polyline). but, at the moment,  I haven't got a clue how to access that using vb (or any other programming language)

nikkipollard

#5
Thanks Andy It is not a huge problem . The simple message box solution you gave works well enough.
The routine is for my own use , I have a note on the form that tells me to use two polylines and a message. And as long as the object returned has vertices I will get something -Even though It might not be what I expected.
The pick point method does have some optional variables that I haven't looked at . I think the answer might be in there.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h