<?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: Sweep Profile From Family in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7767953#M52698</link>
    <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for you, I sat down and implemented a new sample to demonstrate:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/NewFamilySymbolProfile" target="_blank"&gt;https://github.com/jeremytammik/NewFamilySymbolProfile&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  [Transaction( TransactionMode.Manual )]
  public class Command : IExternalCommand
  {
    const string _filepath = "C:/Users/All Users/Autodesk"
      + "/RVT 2018/Libraries/UK/Profiles/Framing/Steel"
      + "/Profiles_L-Angles.rfa";

    public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements )
    {
      UIApplication uiapp = commandData.Application;
      UIDocument uidoc = uiapp.ActiveUIDocument;
      Application app = uiapp.Application;
      Document doc = uidoc.Document;

      Document profile_doc = app.OpenDocumentFile( 
        _filepath );

      // The profile document contains no family sybols:

      FilteredElementCollector symbols
        = new FilteredElementCollector( profile_doc )
          .OfClass( typeof( FamilySymbol ) );

      Debug.Assert( 0 == symbols.GetElementCount(), 
        "expected no family symbol" );

      // Load the profile family to generate them:

      FamilySymbol profile_symbol = null;

      using( Transaction tx = new Transaction( doc ) )
      {
        tx.Start( "Load Profile Family" );

        Family family;

        doc.LoadFamily( _filepath, out family );

        tx.Commit();

        ISet&amp;lt;ElementId&amp;gt; ids = family.GetFamilySymbolIds();

        foreach( ElementId id in ids )
        {
          profile_symbol = doc.GetElement( id ) 
            as FamilySymbol;

          Debug.Print( profile_symbol.Name );
        }
      }

      // Generate the family symbol profile:

      FamilySymbolProfile fsp = null;

      if( null != profile_symbol )
      {
        using( Transaction tx = new Transaction( doc ) )
        {
          tx.Start( "Create FamilySymbolProfile" );
          fsp = app.Create.NewFamilySymbolProfile( 
            profile_symbol );
          tx.Commit();
        }
      }

      return Result.Succeeded;
    }
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The comments explain all there is to know, I hope.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
    <pubDate>Sat, 10 Feb 2018 15:12:47 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2018-02-10T15:12:47Z</dc:date>
    <item>
      <title>Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7751112#M52692</link>
      <description>&lt;P&gt;Simply, I want to pass a profile from an existing profile family to FamilyCreate.NewSweep().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/load-profile-for-newsweep-command/td-p/5117864" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/load-profile-for-newsweep-command/td-p/5117864&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy's comments from this post indicate to me that the profile family cannot be passed directly, but that the profile geometry needs to be recreated. Am I reading this correctly?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;You can certainly retrieve a profile for a sweep operation from a family file.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;However, the family file does not provide any provision for storing a profile per se, so you will have to make use of the other geometrical options available in that context to define some kind of geometry specifying the sweep profile.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;You can then parse that geometry, extract the profile information, and put together the required curve array in your add-in.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned in some other Sweep posts, there are many samples that create a new profile, but none that accept a FamilySymbolProfile directly. Can this be done?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, Dale&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 10:00:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7751112#M52692</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2018-02-05T10:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7752529#M52693</link>
      <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am checking with the development team for you...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 17:31:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7752529#M52693</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-02-05T17:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7756837#M52694</link>
      <description>&lt;P&gt;Hi Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;your question was discussed here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://revit312.rssing.com/browser.php?indx=59521139&amp;amp;item=183" target="_blank"&gt;Sweep using profile family&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the correct answer was given. Please take a look.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One first needs to create FamilySymbolProfile object from FamilySymbol of the profile Family:&lt;/P&gt;
&lt;P&gt;FamilySymbolProfile Application.NewFamilySymbolProfile(FamilySymbol familySymbol);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then use FamilyFactory.NewSweep() method using FamilySymbolProfile&amp;nbsp;as SweepProfile.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;-Boris.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 21:36:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7756837#M52694</guid>
      <dc:creator>bshafiro</dc:creator>
      <dc:date>2018-02-06T21:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7757716#M52695</link>
      <description>&lt;P&gt;Dear Boris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your helpful answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The link you specified does not work&amp;nbsp;for me, but in turn leads to this one, which does:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/sweep-using-profile-family/m-p/6057115" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/sweep-using-profile-family/m-p/6057115&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 06:55:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7757716#M52695</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-02-07T06:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7758028#M52696</link>
      <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since this question has been asked twice now, and there appears to be a simple solution, it might make sense to add a code snippet demonstrating the proper approach to The Building Coder samples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/the_building_coder_samples" target="_blank"&gt;https://github.com/jeremytammik/the_building_coder_samples&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have a suitable sample profile family at hand, or can you point to an existing one in the standard Revit installation, and create a simple generic minimal reproducible case showing haw to use it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 09:36:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7758028#M52696</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-02-07T09:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7758601#M52697</link>
      <description>&lt;P&gt;Hi Jeremy, I have read these various posts at length, and done plenty of experimentation, but clearly&amp;nbsp;I am missing something obvious. I have an overloaded function to create the sweep; the profile based one is perfect. I simply cannot see how the use the FamilySymbolProfile&lt;/P&gt;
&lt;PRE&gt;// 20180207 to use a profile
        public static Sweep CreateSweep(RvtDoc pDoc, ReferenceArray pSweepPath, SweepProfile pSweepProfile)
        {
            Sweep sweep3D = pDoc.FamilyCreate.NewSweep(true, pSweepPath, pSweepProfile, 0, ProfilePlaneLocation.Start);
            // note elementId = sweep3D.Id
            return sweep3D;
        }


        // 20180207 to use profile family
        public static Sweep CreateSweep(RvtDoc pDoc, ReferenceArray pSweepPath, FamilySymbolProfile pFamilySymbolProfile)
        {
            Sweep sweep3D = pDoc.FamilyCreate.NewSweep(true, pSweepPath, pFamilySymbolProfile, 0, ProfilePlaneLocation.Start);
            // note elementId = sweep3D.Id
            return sweep3D;
        }&lt;/PRE&gt;
&lt;P&gt;This is probably laughably wrong, but it is not like I haven't tried ("NewFamilySymbolProfile doesn't exisit in this context").&lt;/P&gt;
&lt;PRE&gt;public static FamilySymbolProfile GetSweepProfileFamily(RvtDoc pDoc, string pstrProfileFamilyName)
        {
            FamilySymbol fs = (from elem in new FilteredElementCollector(pDoc)
                                       .OfClass(typeof(FamilySymbol))
                                        let type = elem as FamilySymbol
                                        where type.FamilyName == pstrProfileFamilyName
                                        select type).FirstOrDefault();
            
            FamilySymbolProfile fsp = new Autodesk.Revit.Creation.Application.NewFamilySymbolProfile(fs);

            return fsp;
        }&lt;/PRE&gt;
&lt;P&gt;So I haven't got as far as testing this against the CreateSweep routine.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 13:27:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7758601#M52697</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2018-02-07T13:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7767953#M52698</link>
      <description>&lt;P&gt;Dear Dale,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for you, I sat down and implemented a new sample to demonstrate:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/NewFamilySymbolProfile" target="_blank"&gt;https://github.com/jeremytammik/NewFamilySymbolProfile&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  [Transaction( TransactionMode.Manual )]
  public class Command : IExternalCommand
  {
    const string _filepath = "C:/Users/All Users/Autodesk"
      + "/RVT 2018/Libraries/UK/Profiles/Framing/Steel"
      + "/Profiles_L-Angles.rfa";

    public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements )
    {
      UIApplication uiapp = commandData.Application;
      UIDocument uidoc = uiapp.ActiveUIDocument;
      Application app = uiapp.Application;
      Document doc = uidoc.Document;

      Document profile_doc = app.OpenDocumentFile( 
        _filepath );

      // The profile document contains no family sybols:

      FilteredElementCollector symbols
        = new FilteredElementCollector( profile_doc )
          .OfClass( typeof( FamilySymbol ) );

      Debug.Assert( 0 == symbols.GetElementCount(), 
        "expected no family symbol" );

      // Load the profile family to generate them:

      FamilySymbol profile_symbol = null;

      using( Transaction tx = new Transaction( doc ) )
      {
        tx.Start( "Load Profile Family" );

        Family family;

        doc.LoadFamily( _filepath, out family );

        tx.Commit();

        ISet&amp;lt;ElementId&amp;gt; ids = family.GetFamilySymbolIds();

        foreach( ElementId id in ids )
        {
          profile_symbol = doc.GetElement( id ) 
            as FamilySymbol;

          Debug.Print( profile_symbol.Name );
        }
      }

      // Generate the family symbol profile:

      FamilySymbolProfile fsp = null;

      if( null != profile_symbol )
      {
        using( Transaction tx = new Transaction( doc ) )
        {
          tx.Start( "Create FamilySymbolProfile" );
          fsp = app.Create.NewFamilySymbolProfile( 
            profile_symbol );
          tx.Commit();
        }
      }

      return Result.Succeeded;
    }
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The comments explain all there is to know, I hope.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2018 15:12:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7767953#M52698</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-02-10T15:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7767984#M52699</link>
      <description>&lt;P&gt;Hi Jeremy, I haven't tested yet, but let me say thanks in advance of a presumed successful run. Your code will give me a chance to review&amp;nbsp;why I found it so difficult.&amp;nbsp;Dale&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2018 15:55:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7767984#M52699</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2018-02-10T15:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7769017#M52700</link>
      <description>&lt;P&gt;I now published and documented a complete NewFamilySymbolProfile sample add-in to demonstrate the steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2018/02/newfamilysymbolprofile-sample-add-in.html" target="_blank" rel="nofollow noopener noreferrer"&gt;http://thebuildingcoder.typepad.com/blog/2018/02/newfamilysymbolprofile-sample-add-in.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/NewFamilySymbolProfile" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/jeremytammik/NewFamilySymbolProfile&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2018 15:52:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7769017#M52700</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-02-11T15:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sweep Profile From Family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7773818#M52701</link>
      <description>&lt;P&gt;100% Success. Full marks. Dale&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 12:38:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7773818#M52701</guid>
      <dc:creator>Dale.Bartlett</dc:creator>
      <dc:date>2018-02-13T12:38:42Z</dc:date>
    </item>
  </channel>
</rss>

