<?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: offset in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5019778#M76836</link>
    <description>&lt;P&gt;What vector are you passing in as the reference direction? Looks like you passed in the face normal or XYZ.BasisZ.&amp;nbsp;&lt;SPAN style="line-height: 1.2;"&gt;Try PlanarFace.get_Vector(0) or something else parallel to the ceiling plane.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.2;"&gt;I've just tried using &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.2;"&gt;NewFamilyInstance(Reference reference, XYZ location, XYZ referenceDirection, FamilySymbol symbol)&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.2;"&gt;&amp;nbsp;and it does indeed work for a sprinkler family. Not all families are created in the same way though, see what info you get from FamilySymbol.Family.FamilyPlacementType, the sprinkler I used was "WorkPlaneBased" and a light family I tried was "OneLevelBasedHosted" which required a Level and the actual host element instead of a face.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you said the original method you used was kind of working, but I think you were just using the top face for placement.&amp;nbsp;&lt;SPAN style="line-height: 1.2;"&gt;If you were to compute the normal of each face and ensure that the one you are using is pointing downward you'll be back in business I'm sure.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 May 2014 13:43:06 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-05-08T13:43:06Z</dc:date>
    <item>
      <title>offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5013776#M76831</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While placing sprinkles/Ceiling Lights on ceilings I am trying to offset them by a negative value so that they get placed below the ceiling but somehow the sprinkers/Ceiling Lights are getting placed on top of it. Kindly help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code to place ceiling&amp;nbsp;sprinkers/Ceiling Lights is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public static FamilyInstance InsertCeilingElements(Document doc, XYZ location, String FamilyName, Element host,double offset)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;FamilySymbol symbol = null;&lt;BR /&gt;foreach (FamilySymbol symbq in fsym)&lt;BR /&gt;{&lt;BR /&gt;String dd1 = symbq.Name;&lt;BR /&gt;String ff = symbq.Category.Name;&lt;BR /&gt;Family fm = symbq.Family;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Boolean fnd = false;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;String[] Famarr = FamilyName.Split(new string[] { "=&amp;gt;" }, StringSplitOptions.None);&lt;BR /&gt;if (dd1 == Famarr[1] &amp;amp;&amp;amp; ff == Famarr[0])&lt;BR /&gt;{&lt;BR /&gt;&lt;SPAN style="line-height: 1.2;"&gt;symbol = symbq;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.2;"&gt;fnd = true;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;break;&lt;BR /&gt;}&lt;BR /&gt;if (fnd == true)&lt;BR /&gt;{&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;FamilyInstance Finst= null;&lt;BR /&gt;using (Transaction t = new Transaction(doc, "Place Instance"))&lt;BR /&gt;{&lt;BR /&gt;t.Start();&lt;BR /&gt;Ceiling ceil = (Ceiling)host;&lt;BR /&gt;Options opt1 = Command.app.Create.NewGeometryOptions();&lt;BR /&gt;opt1.ComputeReferences = true;&lt;BR /&gt;ceil.get_Geometry(opt1);&lt;BR /&gt;GeometryElement geo = ceil.get_Geometry(opt1);&lt;/P&gt;&lt;P&gt;PlanarFace ceilingBottom = null;&lt;/P&gt;&lt;P&gt;foreach (GeometryObject obj in geo.Objects)&lt;BR /&gt;{&lt;BR /&gt;Solid solid = obj as Solid;&lt;BR /&gt;&lt;BR /&gt;if (null != solid)&lt;BR /&gt;{&lt;BR /&gt;foreach (Face face in solid.Faces)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;PlanarFace pf = face as PlanarFace;&lt;/P&gt;&lt;P&gt;if (null != pf)&lt;BR /&gt;{&lt;BR /&gt;XYZ normal = pf.Normal;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ceilingBottom = pf;&lt;BR /&gt;XYZ x = new XYZ(0, 0, 0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Finst= doc.Create.NewFamilyInstance(face, location, x, symbol);&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Finst.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).Set(-150);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;t.Commit();&lt;BR /&gt;&lt;SPAN style="line-height: 1.2;"&gt;break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;return Finst;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2014 03:55:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5013776#M76831</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-06T03:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5018582#M76832</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PlanarFace pf = face as PlanarFace;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;XYZ normal = &lt;STRONG&gt;pf.Normal&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In practice I've found that the vectors obtained using both Planarface.Normal and the Transform returned by PlanarFace.ComputeDerivitives() are unreliable and tend to be the opposite of what they should be (but not always...).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead you should use the PlanarFace.&lt;STRONG&gt;ComputeNormal()&lt;/STRONG&gt; method, I usually just pass in UV.Zero and to date I've had no issues.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px; line-height: 1.2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px; line-height: 1.2;"&gt;Edit:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px; line-height: 1.2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Also, after looking at your code again, you are just taking the first face that you find and then throwing the family instance on it without checking whether it is indeed the bottom face of the ceiling, you could check the face normal for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A better way to get the bottom face of a host element is to use &lt;STRONG&gt;HostObjectUtils.GetBottomFaces()&lt;/STRONG&gt; and then directly use the references returned for placement using the appropriate overload of NewFamilyInstance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And one more tip. Move that &lt;STRONG&gt;t.Commit()&lt;/STRONG&gt; statement out of the foreach loop, calling Commit() multiple times will throw an exception, the only thing saving you at the moment is the break; directly below it. I hope you don't take this as hash criticism, just trying to be helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2014 00:13:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5018582#M76832</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-08T00:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5018834#M76833</link>
      <description>&lt;P&gt;Hi Scott,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using&amp;nbsp;&lt;STRONG&gt;HostObjectUtils.GetBottomFaces()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp; returns error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;IList&amp;lt;Reference&amp;gt; references = HostObjectUtils.GetBottomFaces(ceil);&lt;BR /&gt;Face lface=null;&lt;BR /&gt;foreach (Reference myRef in references)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;lface = ceil.GetGeometryObjectFromReference(myRef) as Face;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;finstance&amp;nbsp;= doc.Create.NewFamilyInstance(lface, location, x, symbol);&lt;BR /&gt;}&lt;BR /&gt;catch (Exception er)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;MessageBox.Show(er.ToString());&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Autodesk.Revit.Exceptions.ArgumentException: The Reference of the input face is null. &amp;nbsp;If the face was obtained from Element.Geometry, make sure to turn on the option 'ComputeReferences'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The revit file which I am running this tool has a single ceiling element.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also I need to know Can I offset all family instances or there are limitations to it:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;finstance.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).Set(offsetvalue);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks &amp;amp; regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2014 04:46:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5018834#M76833</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-08T04:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5018938#M76834</link>
      <description>&lt;P&gt;Hmm, that seems strange, I'd check whether the output from GetGeometryObjectFromReference()&amp;nbsp;succesfully being cast to Face.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try using the reference directly instead by using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px; line-height: 1.2;"&gt;NewFamilyInstance(Reference reference, XYZ location, XYZ referenceDirection, FamilySymbol symbol)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In regard to the offset parameter question, I'm not sure off the top of my head, hopefully someone else can jump in on that one.&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2014 07:04:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5018938#M76834</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-08T07:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5019042#M76835</link>
      <description>&lt;P&gt;Scott that was very sweet and gentle. Such a quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using&amp;nbsp;&lt;SPAN&gt;NewFamilyInstance(Reference reference, XYZ location, XYZ referenceDirection, FamilySymbol symbol) also returned error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;reference direction is parallel to face normal at insertion point.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am able ro place elements on ceiling with the code I posted initially but they get placed above ceiling so I need to offset the placed elements by a negative value so that they come under the ceiling but some elements are able to offset but some not. That was the reason I asked that can offset be applied to all family instances.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG title="ceilplacement.png" alt="ceilplacement.png" border="0" align="center" src="https://forums.autodesk.com/t5/image/serverpage/image-id/99268i3D8ED254B076F121/image-size/original?v=mpbl-1&amp;amp;px=-1" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks &amp;amp; Regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2014 08:06:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5019042#M76835</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-08T08:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5019778#M76836</link>
      <description>&lt;P&gt;What vector are you passing in as the reference direction? Looks like you passed in the face normal or XYZ.BasisZ.&amp;nbsp;&lt;SPAN style="line-height: 1.2;"&gt;Try PlanarFace.get_Vector(0) or something else parallel to the ceiling plane.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.2;"&gt;I've just tried using &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.2;"&gt;NewFamilyInstance(Reference reference, XYZ location, XYZ referenceDirection, FamilySymbol symbol)&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.2;"&gt;&amp;nbsp;and it does indeed work for a sprinkler family. Not all families are created in the same way though, see what info you get from FamilySymbol.Family.FamilyPlacementType, the sprinkler I used was "WorkPlaneBased" and a light family I tried was "OneLevelBasedHosted" which required a Level and the actual host element instead of a face.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you said the original method you used was kind of working, but I think you were just using the top face for placement.&amp;nbsp;&lt;SPAN style="line-height: 1.2;"&gt;If you were to compute the normal of each face and ensure that the one you are using is pointing downward you'll be back in business I'm sure.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2014 13:43:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5019778#M76836</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-08T13:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5021744#M76837</link>
      <description>&lt;P&gt;Dear Scott,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PlanarFace.get_Vector(0) worked like a charm. Thanks a ton.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also wanted your valuable advice on revit programming from career perspective. I have been using revit api from last two years.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks &amp;amp; Regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2014 05:43:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5021744#M76837</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-09T05:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5021892#M76838</link>
      <description>&lt;P&gt;Dear Scott,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A little help please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;say I have x,y points 234,56. when I place an element in linked cad which is linked using origin to origin the element gets placed perfectly. but in linked cad using center that element gets placed somewhere else.&lt;/P&gt;&lt;P&gt;Is there a way where I can convert these xy points so that they become suitable for center to center linked cad also.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2014 08:10:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5021892#M76838</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-09T08:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: offset</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5024068#M76839</link>
      <description>&lt;P&gt;Sorry, I've not had any dealings with imported CAD elements so I can't be of much help.&lt;/P&gt;</description>
      <pubDate>Sat, 10 May 2014 09:29:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/offset/m-p/5024068#M76839</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-05-10T09:29:33Z</dc:date>
    </item>
  </channel>
</rss>

