<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Place Lights on Selected 3D points in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6218058#M66913</link>
    <description>&lt;P&gt;What? So you want to place &amp;nbsp;the lights on top of the columns?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also In your code:&lt;/P&gt;&lt;P&gt;FamilyInstance fi1 = doc.Create.NewFamilyInstance(startPoint1, symbol1, level, light);&amp;nbsp;&lt;/P&gt;&lt;P&gt;is not included in a transaction,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;amp;&lt;/P&gt;&lt;P&gt;level is always null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This could cause the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2016 10:09:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-03-16T10:09:25Z</dc:date>
    <item>
      <title>Place Lights on Selected 3D points</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6216393#M66910</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I want to place Lights on selected 3D points.I selected 3D points from active view and place Lights on that points,But its give me run time errror.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using System;&lt;BR /&gt;using Autodesk.Revit.DB;&lt;BR /&gt;using Autodesk.Revit.UI;&lt;BR /&gt;using Autodesk.Revit.ApplicationServices;&lt;BR /&gt;using Autodesk.Revit.UI.Selection;&lt;BR /&gt;using Autodesk.Revit.DB.Structure;&lt;/P&gt;&lt;P&gt;namespace FamilyPlacing&lt;BR /&gt;{&lt;BR /&gt;[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]&lt;BR /&gt;public class Class1 : IExternalCommand&lt;BR /&gt;{&lt;BR /&gt;public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)&lt;BR /&gt;{&lt;BR /&gt;UIApplication uiapp = commandData.Application;&lt;BR /&gt;UIDocument uidoc = uiapp.ActiveUIDocument;&lt;BR /&gt;Application app = uiapp.Application;&lt;BR /&gt;Document doc = uidoc.Document;&lt;/P&gt;&lt;P&gt;XYZ point_in_3d;&lt;/P&gt;&lt;P&gt;if (SetWorkPlaneAndPickObject(uidoc, out point_in_3d))&lt;BR /&gt;{&lt;BR /&gt;TaskDialog.Show("3D Point Selected",&lt;BR /&gt;"3D point picked on the plane"&lt;BR /&gt;+ " defined by the selected face: "&lt;BR /&gt;+ "X: " + point_in_3d.X.ToString()&lt;BR /&gt;+ ", Y: " + point_in_3d.Y.ToString()&lt;BR /&gt;+ ", Z: " + point_in_3d.Z.ToString());&lt;/P&gt;&lt;P&gt;double x, y, z;&lt;BR /&gt;x = point_in_3d.X;&lt;BR /&gt;y = point_in_3d.Y;&lt;BR /&gt;z = point_in_3d.Z;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;StructuralType light = StructuralType.NonStructural;&lt;BR /&gt;FilteredElementCollector collector1 = new FilteredElementCollector(doc);&lt;BR /&gt;collector1.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_LightingFixtures);&lt;BR /&gt;FamilySymbol symbol1 = collector1.FirstElement() as FamilySymbol;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;//Here I want to place Lights&lt;/STRONG&gt;&lt;BR /&gt;Level level = null;&lt;BR /&gt;if (level.Name.Equals("Level 1"))&lt;BR /&gt;{&lt;BR /&gt;XYZ startPoint1 = new XYZ(x, y, z);&lt;BR /&gt;FamilyInstance fi1 = doc.Create.NewFamilyInstance(startPoint1, symbol1, level, light);&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return Result.Succeeded;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;message = "3D point selection failed";&lt;BR /&gt;return Result.Failed;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private bool SetWorkPlaneAndPickObject(UIDocument uidoc, out XYZ point_in_3d)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;point_in_3d = null;&lt;BR /&gt;Document doc = uidoc.Document;&lt;/P&gt;&lt;P&gt;Reference r = uidoc.Selection.PickObject(&lt;BR /&gt;Autodesk.Revit.UI.Selection.ObjectType.Face,&lt;BR /&gt;"Please select a planar face to define work plane");&lt;BR /&gt;Element e = doc.GetElement(r.ElementId);&lt;BR /&gt;if (null != e)&lt;BR /&gt;{&lt;BR /&gt;PlanarFace face = e.GetGeometryObjectFromReference(r)&lt;BR /&gt;as PlanarFace;&lt;/P&gt;&lt;P&gt;GeometryElement geoEle = e.get_Geometry(new Options());&lt;BR /&gt;Transform transform = null;&lt;/P&gt;&lt;P&gt;foreach (GeometryObject gObj in geoEle)&lt;BR /&gt;{&lt;BR /&gt;GeometryInstance gInst = gObj as GeometryInstance;&lt;BR /&gt;if (null != gInst)&lt;BR /&gt;transform = gInst.Transform;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (face != null)&lt;BR /&gt;{&lt;BR /&gt;// face.Normal face.FaceNormal&lt;BR /&gt;Plane plane = null;&lt;/P&gt;&lt;P&gt;if (null != transform)&lt;BR /&gt;{//uiDoc.ActiveView.ViewDirection, uiDoc.ActiveView.Origin&lt;BR /&gt;//transform.OfVector(face.FaceNormal),&lt;BR /&gt;//transform.OfPoint(face.Origin)&lt;BR /&gt;plane = new Plane(uidoc.ActiveView.ViewDirection, uidoc.ActiveView.Origin);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;plane = new Plane(face.FaceNormal, face.Origin);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Transaction t = new Transaction(doc);&lt;/P&gt;&lt;P&gt;t.Start("Temporarily set work plane"&lt;BR /&gt;+ " to pick point in 3D");&lt;BR /&gt;&lt;BR /&gt;SketchPlane sp = SketchPlane.Create(doc,plane);&lt;/P&gt;&lt;P&gt;uidoc.ActiveView.SketchPlane = sp;&lt;BR /&gt;uidoc.ActiveView.ShowActiveWorkPlane();&lt;/P&gt;&lt;P&gt;try&lt;BR /&gt;{&lt;BR /&gt;point_in_3d = uidoc.Selection.PickPoint(&lt;BR /&gt;"Please pick a point on the plane"&lt;BR /&gt;+ " defined by the selected face");&lt;BR /&gt;}&lt;BR /&gt;catch (OperationCanceledException)&lt;BR /&gt;{&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;t.RollBack();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return null != point_in_3d;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 13:17:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6216393#M66910</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-15T13:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Place Lights on Selected 3D points</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6216627#M66911</link>
      <description>&lt;P&gt;Its a bit hard to look at your code its not formatted...&lt;/P&gt;&lt;P&gt;but according to the erros you have a unexpected unhandled null value on line 46.. in debug it would be the first place where to look.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:11:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6216627#M66911</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-15T15:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Place Lights on Selected 3D points</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6217891#M66912</link>
      <description>&lt;P&gt;Instead of placing lights I place Structural Column and it run successfull. And next thing I want to do that I want to select multiple points at a time and place the column. How can I do this?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 07:35:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6217891#M66912</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T07:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Place Lights on Selected 3D points</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6218058#M66913</link>
      <description>&lt;P&gt;What? So you want to place &amp;nbsp;the lights on top of the columns?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also In your code:&lt;/P&gt;&lt;P&gt;FamilyInstance fi1 = doc.Create.NewFamilyInstance(startPoint1, symbol1, level, light);&amp;nbsp;&lt;/P&gt;&lt;P&gt;is not included in a transaction,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;amp;&lt;/P&gt;&lt;P&gt;level is always null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This could cause the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 10:09:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/place-lights-on-selected-3d-points/m-p/6218058#M66913</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T10:09:25Z</dc:date>
    </item>
  </channel>
</rss>

