ciao a tutti!
é la prima votla che mi capita una cosa del genere percio mi trovo spiazzato!
sto programmando una DLL per un programma. cé un timer, e cé una funzione.
ho bisogno di richiamare la funzione all interno del timer, ma mi dice che non cé un istanza. se peró eseguo la stessa funzione dalla sub principale funziona. spero di non aver fatto casino spiegando perche sono abbastanza green...
ecco a voi del codice esempio:
NON funziona:
codice:
Dim uiapp As UIApplication
Dim doc As Document
Public Function Execute(commandData As Autodesk.Revit.UI.ExternalCommandData, ByRef message As String, elements As Autodesk.Revit.DB.ElementSet) As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute
'Get application and document objects
uiapp = commandData.Application
doc = uiapp.ActiveUIDocument.Document
Dim viewCollector As New FilteredElementCollector(doc)
viewCollector.OfClass(GetType(View))
myArr = getlist()
AddHandler t.Elapsed, AddressOf OnTimedEvent
t.Enabled = True
GC.KeepAlive(t)
Return vbNull
End Function
Public Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
loadview() <--------SE LA RICHIAMO DA QUI SI IMPIANTA (VEDI SOTTO)
end sub
Public Sub loadview()
Dim viewCollector As New FilteredElementCollector(doc)
viewCollector.OfClass(GetType(View))
For Each viewElement As Element In viewCollector
Dim view As View = DirectCast(viewElement, View)
If view.ToString = "Autodesk.Revit.DB.View3D" And view.ViewType <> 124 And Not view.IsTemplate Then
'set active and render
uiapp.ActiveUIDocument.ActiveView = view <------QUI SI IMPIANTA!
currentstep = 1
End If
Next
End Sub
funziona:
codice:
Dim uiapp As UIApplication
Dim doc As Document
Public Function Execute(commandData As Autodesk.Revit.UI.ExternalCommandData, ByRef message As String, elements As Autodesk.Revit.DB.ElementSet) As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute
'Get application and document objects
uiapp = commandData.Application
doc = uiapp.ActiveUIDocument.Document
Dim viewCollector As New FilteredElementCollector(doc)
viewCollector.OfClass(GetType(View))
myArr = getlist()
AddHandler t.Elapsed, AddressOf OnTimedEvent
t.Enabled = True
GC.KeepAlive(t)
loadview() <-----------QUI FUNZIONA!!
Return vbNull
End Function
Public Sub loadview()
Dim viewCollector As New FilteredElementCollector(doc)
viewCollector.OfClass(GetType(View))
For Each viewElement As Element In viewCollector
Dim view As View = DirectCast(viewElement, View)
If view.ToString = "Autodesk.Revit.DB.View3D" And view.ViewType <> 124 And Not view.IsTemplate Then
'set active and render
uiapp.ActiveUIDocument.ActiveView = view <------QUI SI IMPIANTA!
currentstep = 1
End If
Next
End Sub
perche il timer non riconosce l istanza creata all inizio???