how to access select object properties

Discuss and ask questions about CADViewX (Lite and Pro versions).

Moderators: support, SDS, admin

Post Reply
ronanry
Posts: 2
Joined: 20 Jul 2011, 20:38

how to access select object properties

Post by ronanry » 20 Jul 2011, 21:39

Hi all,

First of all, thanks for your works ! Cadviewx is exactly what i was seeking for : an activeX available in vb.net to zoom in/out in code !!

However, if i come to this forum is to ask you something.
in my vb.net appli, how can i obtain the properties in code for the selected items in my activeX.
like you can do in Acad with the following code :

Dim ssetObj As IAcadSelectionSet
Set ssetObj = ThisDrawing.SelectionSets(0)
compte = ssetObj.Count
If compte > 1 Then
Debug.Print "only the first selected item will be used"
End If
If compte = 0 Then
Debug.Print "you don't have made any selection"
Exit Sub
End If
If ssetObj.Item(0).ObjectName = "AcDbMText" Then
Debug.Print "selection ok : " & ssetObj.Item(0).TextString
End If


For example, i have a DbMText selected, how can i retieved the text inside (or his coordinates) and how to detect that a point have been selected (<== this point is just for fun... if it's impossible, i'll use a button)


I have already read this topic : http://www.cadsofttools.com/forum/viewt ... =15&t=2327
but what i like is how to retrieve the handler or i/j of the selected item in my dwg

i read this one too : http://www.cadsofttools.com/forum/viewt ... =15&t=2239 .... but not sure that cadimport is what i need


My software should only do :
- zoom in/out on a specific point
- when you select an item (Mtext) and click a button , retrieve the text on the mtext <== datas that appears in "properties" tab on the left in fact
Thanks in advance for any help

support
Posts: 2930
Joined: 30 Mar 2005, 11:36
Contact:

Re: how to access select object properties

Post by support » 21 Jul 2011, 13:10

Hello.
Generally CADViewX Pro allows access selected entities using Editor component. Unfortunately CADViewX current version provides entities limited access from API. For example MText entity can't be accessed programmatically though MTexts supported internally. However MText can be represented as Insert that contains Text entity in CADViewX library. This makes possible a workaround for retrieving a text. The following VB.NET example shows accessing the text content of selected MText object:

Code: Select all

        Dim selected As CADViewLib.Entity
        Dim str As String
        selected = CADViewX1.GetCADEditor().Selected
        If ((selected.Count = 1) And (selected.Entities(0).EntID = CADViewLib.TEntityID.eidMText)) Then
            str = selected.Entities(0).Block.Entities(0).Text
        End If
CAD Import .NET allows access to MTexts from API and provides required functionality as well.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

ronanry
Posts: 2
Joined: 20 Jul 2011, 20:38

Re: how to access select object properties

Post by ronanry » 21 Jul 2011, 14:14

Exactly what i need
(i don't have to access to "the object" MText, only the value ;))

but, you confirm that only PRO version is able to do this ....


concerning Lite version, is it able to do this :

Code: Select all

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim MonX As Double = 1754188
        Dim MonY As Double = 2255045
        Dim R As CADViewLib.Rect3D
        R = New CADViewLib.Rect3D
        R.Left = CDbl(MonX - 100)
        R.Top = CDbl(MonY - 100)
        R.Z1 = CDbl(0)
        R.Right = CDbl(MonX + 100)
        R.Bottom = CDbl(MonY + 100)
        R.Z2 = CDbl(0)
        AxCADViewX1.ShowRect(R)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        AxCADViewX1.PrintViewArea = True
        AxCADViewX1.PrintImage()
    End Sub

support
Posts: 2930
Joined: 30 Mar 2005, 11:36
Contact:

Re: how to access select object properties

Post by support » 21 Jul 2011, 16:22

Hello.
CADViewX Lite doesn't include selection tool. Of course entities can be accessed programmatically like with Pro version.
The result of the snippet you have posted is printing specified area of a drawing.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply