Thanks,
David
Ken
David Mulligan wrote in message <79it76$ph...@adesknews2.autodesk.com>...
Public Sub MainProgram() 'sub routine
Dim ReturnedSelectionSet Object
ReturnedSelectionSet Object = MakeSelection() 'call my function
End Sub
MakeSelection()As ? 'function
MakeSelection = returnSelectionSetObjectToSub
End Function
Here's some code that gets a selectionset from a function.
Make sure you have the 'Autocad R14 Object Library' checked in
'Project\References' in your VB editor.
Regards,
Arno van Eeuwen
Option Explicit
Private Acad As Object
Private Document As Object
Public Sub Main()
Dim MainSset As AcadSelectionSet
Set Acad = GetObject(, "AutoCAD.Application")
Set Document = Acad.ActiveDocument
Set MainSset = GetSomethingFromScreen
MsgBox "Selected " & MainSset.Count & " items"
End Sub
Private Function GetSomethingFromScreen() As AcadSelectionSet
Dim Sset As AcadSelectionSet
Set Sset = Document.SelectionSets.Add("NameIt")
Sset.SelectOnScreen
Set GetSomethingFromScreen = Sset
End Function
In the procedure that make the call:
...
Dim ss as acadselectionset
set ss = ThisDrawing.Selectionsets.Add("ss")
' Make call to get the selection set
If GetMySS(ss) Then
' Do somthing with selectionset ss
end if
...
Follow is GetMySS function, I like to put a return as True/False so I'll
know if the function is success or fail
Public Function GetMySS(ss As AcadSelectionset) As boolean
' Reset the return value to fail
' Do some kine of select here
if ss.count = 0 then
GetMySS = False
else
GetMyss = True
end if
End Function
WARNING: ss Must be ByRef (default) can't not use ByVal event if it is any
VB(A) data type.
You don't have to have a return value of true, false but you need to check
the reference variable properties in order to know if the called function
operate success or not.
Ken