How to use selected objects

How to use selected objects

Anonymous
Not applicable
315 Views
2 Replies
Message 1 of 3

How to use selected objects

Anonymous
Not applicable
Dear friends,

here it is a code to select some lines with a section on screen

after selecting the lines , I want to get the start point of every line and the end point

but the VBA has a limitation to make that


look at this code :

Dim ret As Boolean

Me.Hide

ret = AddingSelectionSetNamedThisName("HorizontalLines")

ThisDrawing.Utility.prompt vbCrLf & " Select Horizontal Lines :"


Dim FilterType(0) As Integer
Dim FilterData(0) As Variant

FilterType(0) = 0
FilterData(0) = "line" '"line" ' "3dface" , and so on

SSObject.SelectOnScreen FilterType, FilterData

SSObject.Highlight True

Dim i As Long

Dim LineOptained As AcadObject
Dim LineOptainedHandle As Long


Dim StartPoint As Variant
''Dim EndPoint As Variant

For Each LineOptained In SSObject 'or ThisDrawing.ModelSpace

LineOptainedHandle= LineOptained.Handle

StartPoint = LineOptained.startPoint

i = i + 1

Next

Me.Show

end sub


===========================


the results:
==========

the handle or length of any horizontal line will be determined

but other properties of a line object no

how to get some important properties of the acadEntity selected by the user on screen

like maxPoint, minPoint, GetBounderingBox, startPoint, and EndPoint

notice that all above properties could be determined only when u create a line by Addline

HOW TO WORK AROUND THIS ?????

ANYONE MAY HELP ME PLEASE ???
0 Likes
316 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
What "a limiation", that VBA has, is ?

As my understanding to your code, you want to retrieve StartPoint and
EndPoint (and other possible properties) of an entity in the selectionSet
only the entity is AcadLine. There isn't VBA limitation to prevent you from
doing that:

Dim myLine As AcadLine

For Each LineOptained In SSObject 'or ThisDrawing.ModelSpace

LineOptainedHandle= LineOptained.Handle

''You examine what the entity type is before accessing its properties
If TypeOf LineOptained Is AcadLine Then

'If it is AcadLine, you can access StartPoint/EndPoint properties
Set myLine=LineOptained
StartPoint = myLine.StartPoint
EndPoint=myLine.EndPoint
...
...

Else If TypeOf lineOptained Is ... Then

''If it is something else, access its properties accordingly
...
...

End If

Next

However, if your SelectionSet's filter is set up correctly, it is guaranteed
everything in the SelectionSet is AcadLine. So, there is not need to use
"TypeOf ... Is ..." statement at all. Simply:

For Each LineOptained in SSObj
StartPoint=LineOptained.StartPoint
EndPoint=LineOptained.EndPoint
...
Next

OK, in this case, you do not get Intellisense prompt in VB Editor when
writing code, because LineOptained in SssObj is an generic type AcadEntity,
which points an concrete AcadLine. If this is what you called VBA
limitation, then it is really not. This is called "late-binding"

You can do this to get the Intellisense prompt back this way
(early-binding):

Dim myLine As AcadLine

For Each LineOptained in SSObj
Set myLine=LineOptained
StartPoint=myLine.StartPoint
EndPoint=myLine.EndPoint
...
Next


"maximas2000" wrote in message news:5980948@discussion.autodesk.com...
Dear friends,

here it is a code to select some lines with a section on screen

after selecting the lines , I want to get the start point of every line and
the end point

but the VBA has a limitation to make that


look at this code :

Dim ret As Boolean

Me.Hide

ret = AddingSelectionSetNamedThisName("HorizontalLines")

ThisDrawing.Utility.prompt vbCrLf & " Select Horizontal Lines :"


Dim FilterType(0) As Integer
Dim FilterData(0) As Variant

FilterType(0) = 0
FilterData(0) = "line" '"line" ' "3dface" , and so on

SSObject.SelectOnScreen FilterType, FilterData

SSObject.Highlight True

Dim i As Long

Dim LineOptained As AcadObject
Dim LineOptainedHandle As Long


Dim StartPoint As Variant
''Dim EndPoint As Variant

For Each LineOptained In SSObject 'or ThisDrawing.ModelSpace

LineOptainedHandle= LineOptained.Handle

StartPoint = LineOptained.startPoint

i = i + 1

Next

Me.Show

end sub


===========================


the results:
==========

the handle or length of any horizontal line will be determined

but other properties of a line object no

how to get some important properties of the acadEntity selected by the user
on screen

like maxPoint, minPoint, GetBounderingBox, startPoint, and EndPoint

notice that all above properties could be determined only when u create a
line by Addline

HOW TO WORK AROUND THIS ?????

ANYONE MAY HELP ME PLEASE ???
0 Likes
Message 3 of 3

Anonymous
Not applicable
Sub Ch4_FilterMtext()
Dim sstext As AcadSelectionSet
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
Set sstext = ThisDrawing.SelectionSets.Add("SS2")
FilterType(0) = 0
FilterData(0) = "Circle"
sstext.SelectOnScreen FilterType, FilterData
End Sub

Sub Ch4_FilterBlueCircleOnLayer0()
Dim sstext As AcadSelectionSet
Dim FilterType(2) As Integer
Dim FilterData(2) As Variant
Set sstext = ThisDrawing.SelectionSets.Add("SS4")

FilterType(0) = 0
FilterData(0) = "Circle"

FilterType(1) = 62
FilterData(1) = acBlue

FilterType(2) = 8
FilterData(2) = "0"

sstext.SelectOnScreen FilterType, FilterData

End Sub

Sub Ch4_FilterRelational()
Dim sstext As AcadSelectionSet
Dim FilterType(2) As Integer
Dim FilterData(2) As Variant
Set sstext = ThisDrawing.SelectionSets.Add("SS5")

FilterType(0) = 0
FilterData(0) = "Circle"
FilterType(1) = -4
FilterData(1) = ">="
FilterType(2) = 40
FilterData(2) = 5#

sstext.SelectOnScreen FilterType, FilterData
End Sub

then loop through the selectionset for the objects Message was edited by: Ramya
0 Likes