jdshanks
2006-03-14, 07:54 PM
Using VB.net 2.0 and Revit 9 demo.
Public Function Execute(ByVal commandData As Autodesk.Revit.ExternalCommandData, ByRef message As String, ByVal elements As Autodesk.Revit.ElementSet) As Autodesk.Revit.IExternalCommand.Result Implements Autodesk.Revit.IExternalCommand.Execute
Try
' hard coded family file
Dim fileName As String = "C:\Documents and Settings\All Users\Application Data\Autodesk\Revit Building 9\Imperial Library\Furniture\Bed-Bunk.rfa"
Dim symName As String = "82x36"
Dim str As String = "Loading Family Symbol: " & fileName & vbCr & symName
MsgBox(str)
If (LoadFamilySymbol(fileName, symName) = True) Then
MsgBox("Finaly loaded a stupid family!")
Return Revit.IExternalCommand.Result.Succeeded
End If
Catch ex As Exception
message = ex.Message
Return IExternalCommand.Result.Failed
End Try
End Function
The error I get on "LoadFamilySymol" is "Reference to a non-shared member requires an object reference." Yet the Revit API shows LoadFamilySymbol(String, String) As Boolean as a legit function. What am I doing wrong? Or is there a better way to do this? Thanks for any help.
I admit that I'm a code hack. I just find what works for someone else and change a few variables until it works for me (if it's a language I don't konw very well.)
Public Function Execute(ByVal commandData As Autodesk.Revit.ExternalCommandData, ByRef message As String, ByVal elements As Autodesk.Revit.ElementSet) As Autodesk.Revit.IExternalCommand.Result Implements Autodesk.Revit.IExternalCommand.Execute
Try
' hard coded family file
Dim fileName As String = "C:\Documents and Settings\All Users\Application Data\Autodesk\Revit Building 9\Imperial Library\Furniture\Bed-Bunk.rfa"
Dim symName As String = "82x36"
Dim str As String = "Loading Family Symbol: " & fileName & vbCr & symName
MsgBox(str)
If (LoadFamilySymbol(fileName, symName) = True) Then
MsgBox("Finaly loaded a stupid family!")
Return Revit.IExternalCommand.Result.Succeeded
End If
Catch ex As Exception
message = ex.Message
Return IExternalCommand.Result.Failed
End Try
End Function
The error I get on "LoadFamilySymol" is "Reference to a non-shared member requires an object reference." Yet the Revit API shows LoadFamilySymbol(String, String) As Boolean as a legit function. What am I doing wrong? Or is there a better way to do this? Thanks for any help.
I admit that I'm a code hack. I just find what works for someone else and change a few variables until it works for me (if it's a language I don't konw very well.)