I understand what you are trying to do. The Revit API doesn't support selection for non-element objects (as far as I know).
The visualisation is not the important part of your coding. (You would probably do better to turn them straight into beams anyway.)
Here's a proof of concept:
#Region "Imported Namespaces"
Imports System.Linq
Imports Autodesk.Revit
Imports Autodesk.Revit.Attributes
#End Region
<Transaction(TransactionMode.Manual)> _
<Regeneration(RegenerationOption.Manual)> _
<Journaling(JournalingMode.UsingCommandData)> _
Public Class AddBeam
Implements UI.IExternalCommand
Public Function Execute(ByVal commandData As UI.ExternalCommandData, _
ByRef message As String, ByVal elements As DB.ElementSet) _
As UI.Result Implements UI.IExternalCommand.Execute
Dim app As ApplicationServices.Application = commandData.Application.Application
Execute = UI.Result.Failed
Dim doc As DB.Document = commandData.Application.ActiveUIDocument.Document
Dim docUi As UI.UIDocument = commandData.Application.ActiveUIDocument
Dim ref As DB.Reference = _
docUi.Selection.PickObject(UI.Selection.ObjectType.PointOnElement, "Pick element")
Dim elem As DB.Element = doc.GetElement(ref)
Dim geomObject As DB.GeometryObject = _
elem.GetGeometryObjectFromReference(ref)
If TypeOf (geomObject) Is DB.Line Then
Dim line As DB.Line = TryCast(geomObject, DB.Line)
Dim familySymbol As DB.FamilySymbol = New DB.FilteredElementCollector(doc) _
.OfCategory(DB.BuiltInCategory.OST_StructuralFraming) _
.OfClass(GetType(DB.FamilySymbol)) _
.Cast(Of DB.FamilySymbol) _
.FirstOrDefault
Using trans As New DB.Transaction(doc, "Add Beam")
trans.Start()
Dim curve As DB.Curve = line
Dim familyInstance As DB.FamilyInstance = _
doc.Create.NewFamilyInstance(curve, familySymbol, _
doc.ActiveView.GenLevel, DB.Structure.StructuralType.Beam)
trans.Commit()
Return UI.Result.Succeeded
End Using
End If
Return Execute
End Function
End Class
You'll need a framing family in your model.
Cheers,
-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?