Simply, I want to pass a profile from an existing profile family to FamilyCreate.NewSweep().
https://forums.autodesk.com/t5/revit-api-forum/load-profile-for-newsweep-command/td-p/5117864
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?
You can certainly retrieve a profile for a sweep operation from a family file.
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.
You can then parse that geometry, extract the profile information, and put together the required curve array in your add-in.
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?
Thanks, Dale
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Dear Dale,
Thank you for your query.
I am checking with the development team for you...
Cheers,
Jeremy
Hi Dale,
your question was discussed here:
and the correct answer was given. Please take a look.
One first needs to create FamilySymbolProfile object from FamilySymbol of the profile Family:
FamilySymbolProfile Application.NewFamilySymbolProfile(FamilySymbol familySymbol);
and then use FamilyFactory.NewSweep() method using FamilySymbolProfile as SweepProfile.
I hope this helps.
Best regards,
-Boris.
Dear Boris,
Thank you for your helpful answer.
The link you specified does not work for me, but in turn leads to this one, which does:
https://forums.autodesk.com/t5/revit-api-forum/sweep-using-profile-family/m-p/6057115
Cheers,
Jeremy
Dear Dale,
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.
https://github.com/jeremytammik/the_building_coder_samples
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?
http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b
Thank you!
Cheers,
Jeremy
Hi Jeremy, I have read these various posts at length, and done plenty of experimentation, but clearly 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
// 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; }
This is probably laughably wrong, but it is not like I haven't tried ("NewFamilySymbolProfile doesn't exisit in this context").
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; }
So I haven't got as far as testing this against the CreateSweep routine.
Dear Dale,
Just for you, I sat down and implemented a new sample to demonstrate:
https://github.com/jeremytammik/NewFamilySymbolProfile
Here is the code:
[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<ElementId> 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; } }
The comments explain all there is to know, I hope.
Cheers,
Jeremy
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 why I found it so difficult. Dale
I now published and documented a complete NewFamilySymbolProfile sample add-in to demonstrate the steps:
http://thebuildingcoder.typepad.com/blog/2018/02/newfamilysymbolprofile-sample-add-in.html
https://github.com/jeremytammik/NewFamilySymbolProfile
Enjoy!
Cheers,
Jeremy