<?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: How to create an element that belongs to a custom sub category? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11824753#M13339</link>
    <description>&lt;P&gt;Thank you Michel&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3633270"&gt;@TripleM-Dev.net&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This solved my problem!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For future reference. I created my custom category under Site like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Categories categories = doc.Settings.Categories;
Category siteCategory = categories.get_Item(BuiltInCategory.OST_Site);
Category customSubCat = categories.NewSubcategory(siteCategory, "CUSTOM COORDINATES");
doc.Regenerate();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then created a DirecteShape using the following snippet (adopted from the &lt;A href="https://www.revitapidocs.com/2023/bfbd137b-c2c2-71bb-6f4a-992d0dcf6ea8.htm" target="_blank" rel="noopener"&gt;Docs)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;List&amp;lt;Curve&amp;gt; profile = new List&amp;lt;Curve&amp;gt;();

// first create sphere with 2' radius
XYZ center = XYZ.Zero;
double radius = 2.0;
XYZ profile00 = center;
XYZ profilePlus = center + new XYZ(0, radius, 0);
XYZ profileMinus = center - new XYZ(0, radius, 0);

profile.Add(Line.CreateBound(profilePlus, profileMinus));
profile.Add(Arc.Create(profileMinus, profilePlus, center + new XYZ(radius, 0, 0)));

CurveLoop curveLoop = CurveLoop.Create(profile);
SolidOptions options = new SolidOptions(ElementId.InvalidElementId, customSubCat.GetGraphicsStyle(GraphicsStyleType.Projection).Id);

Autodesk.Revit.DB.Frame frame = new Autodesk.Revit.DB.Frame(center, XYZ.BasisX, -XYZ.BasisZ, XYZ.BasisY);


if (Autodesk.Revit.DB.Frame.CanDefineRevitGeometry(frame) == true)
{
    Solid sphere = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, options);

    // create direct shape and assign the sphere shape
    DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_Site));

    ds.ApplicationId = "Application id";
    ds.ApplicationDataId = "Geometry object id";
    ds.SetShape(new GeometryObject[] { sphere });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2023 02:34:13 GMT</pubDate>
    <dc:creator>aryan4WGLU</dc:creator>
    <dc:date>2023-03-16T02:34:13Z</dc:date>
    <item>
      <title>How to create an element that belongs to a custom sub category?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11819388#M13334</link>
      <description>&lt;P&gt;I'd like to create a new custom element with custom geometry in Reivt that belongs to a custom sub category.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have done so far is:&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I have created a new Subcategory using &lt;A href="https://www.revitapidocs.com/2023/aba44eba-9882-54cb-fe52-30553a684c34.htm" target="_blank"&gt;NewSubcategory Method (revitapidocs.com)&lt;/A&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="csharp"&gt;Categories categories = doc.Settings.Categories;
Category siteCategory = categories.get_Item(BuiltInCategory.OST_Site);
Category customCategory = categories.NewSubcategory(siteCategory, "MY COORDINATES");
doc.Regenerate();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 2. I have tried creating a new DetailCurve using&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2023/9a8bd0d3-00dc-7a1c-39dd-e891899764ce.htm" target="_blank"&gt;NewDetailCurve Method (revitapidocs.com)&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;double radius = 10.0;
// Create the circle
Curve circle = Arc.Create(new XYZ(10, 10, 0), 10.0, 0.0, 2.0 * Math.PI, XYZ.BasisX, XYZ.BasisY);
// Create a new detail detailCurve element
DetailCurve detailCurve = doc.Create.NewDetailCurve(doc.ActiveView, circle) as DetailCurve;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I can't figure out how to assign my new `DetailCurve` to my `customCategory` created earlier. Is there a way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My final goal is to be able to create a custom object that its visibility is dependent on my custom category so the user can toggle this from Visibility/Graphics Overrides settings. Is there a better way to do this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 03:53:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11819388#M13334</guid>
      <dc:creator>aryan4WGLU</dc:creator>
      <dc:date>2023-03-14T03:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an element that belongs to a custom sub category?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11819531#M13335</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13252434"&gt;@aryan4WGLU&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try something like this. I have not tested it myself but it should guide you in achieving what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;// get the category to create the subcategory in
Category lineCat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines);

// create a new subcategory
Subcategory customCategory = lineCat.SubCategories.NewSubcategory("MY COORDINATES");
doc.Regenerate();

// create a new DetailCurve object
DetailCurve detailCurve = .....

// assign the subcategory to the DetailCurve
detailCurve.Subcategory = customCategory;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 06:22:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11819531#M13335</guid>
      <dc:creator>moturi.magati.george</dc:creator>
      <dc:date>2023-03-14T06:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an element that belongs to a custom sub category?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11821696#M13336</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13252434"&gt;@aryan4WGLU&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Detail/ModelLine's subcategories are their Styles, you're creating subcategories under the Site Category.&lt;/P&gt;&lt;P&gt;As &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12896310"&gt;@moturi.magati.george&lt;/a&gt; states create SubCategories under the Lines Category (= BuiltInCategory.OST_Lines)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Retrieve the valid styles from the DetailCurve created using: &lt;A title="GetLineStyleIds Method" href="https://www.revitapidocs.com/2023/3e30d0b4-6c74-18bf-043f-2430ff9ac17b.htm" target="_blank" rel="noopener"&gt;GetLineStyleIds Method&lt;/A&gt;, from these chose one (evaluate their name for the correct one)&lt;/P&gt;&lt;P&gt;Apply that style to the created DetailCurve &lt;A title="LineStyle Property" href="https://www.revitapidocs.com/2023/691e64a2-e5ea-b619-4362-1a2c17e23b2f.htm" target="_blank" rel="noopener"&gt;LineStyle Property&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Retrieving the valid linestyles first is important because the Lines Category also contains styles that can't be used on DetailCurves like RoomBoundary lines, Invisible Lines etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 23:00:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11821696#M13336</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2023-03-14T23:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an element that belongs to a custom sub category?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11821746#M13337</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3633270"&gt;@TripleM-Dev.net&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12896310"&gt;@moturi.magati.george&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for getting back to me!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that Detail/ModelLine's subcategories are their styles however that is not what I'm interested in.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to create an element that is assigned to my custom Subcategory created under Site (`OST_SITE`). So in short, I'd like to create a custom element (that basically looks like a circle) that the user can toggle its visibility through the&amp;nbsp;&lt;SPAN&gt;Visibility/Graphics Overrides settings panel. Is this actually possible?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Much appreciate any help here &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 23:51:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11821746#M13337</guid>
      <dc:creator>aryan4WGLU</dc:creator>
      <dc:date>2023-03-14T23:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an element that belongs to a custom sub category?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11823807#M13338</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13252434"&gt;@aryan4WGLU&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A Element with a subcategory in the Site Category would always be a Model element (3D).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you would need to create a Model Family or a Directshape object with a Solid and set it's GraphicsStyleId to one with the correct subcategory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 17:44:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11823807#M13338</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2023-03-15T17:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an element that belongs to a custom sub category?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11824753#M13339</link>
      <description>&lt;P&gt;Thank you Michel&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3633270"&gt;@TripleM-Dev.net&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This solved my problem!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For future reference. I created my custom category under Site like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Categories categories = doc.Settings.Categories;
Category siteCategory = categories.get_Item(BuiltInCategory.OST_Site);
Category customSubCat = categories.NewSubcategory(siteCategory, "CUSTOM COORDINATES");
doc.Regenerate();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then created a DirecteShape using the following snippet (adopted from the &lt;A href="https://www.revitapidocs.com/2023/bfbd137b-c2c2-71bb-6f4a-992d0dcf6ea8.htm" target="_blank" rel="noopener"&gt;Docs)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;List&amp;lt;Curve&amp;gt; profile = new List&amp;lt;Curve&amp;gt;();

// first create sphere with 2' radius
XYZ center = XYZ.Zero;
double radius = 2.0;
XYZ profile00 = center;
XYZ profilePlus = center + new XYZ(0, radius, 0);
XYZ profileMinus = center - new XYZ(0, radius, 0);

profile.Add(Line.CreateBound(profilePlus, profileMinus));
profile.Add(Arc.Create(profileMinus, profilePlus, center + new XYZ(radius, 0, 0)));

CurveLoop curveLoop = CurveLoop.Create(profile);
SolidOptions options = new SolidOptions(ElementId.InvalidElementId, customSubCat.GetGraphicsStyle(GraphicsStyleType.Projection).Id);

Autodesk.Revit.DB.Frame frame = new Autodesk.Revit.DB.Frame(center, XYZ.BasisX, -XYZ.BasisZ, XYZ.BasisY);


if (Autodesk.Revit.DB.Frame.CanDefineRevitGeometry(frame) == true)
{
    Solid sphere = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, options);

    // create direct shape and assign the sphere shape
    DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_Site));

    ds.ApplicationId = "Application id";
    ds.ApplicationDataId = "Geometry object id";
    ds.SetShape(new GeometryObject[] { sphere });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 02:34:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-an-element-that-belongs-to-a-custom-sub-category/m-p/11824753#M13339</guid>
      <dc:creator>aryan4WGLU</dc:creator>
      <dc:date>2023-03-16T02:34:13Z</dc:date>
    </item>
  </channel>
</rss>

