Sweep using profile family

grahamcook
Advocate
Advocate

Sweep using profile family

grahamcook
Advocate
Advocate

I would like to create a sweep using the NewSweep method.  One of the expected parameters is Profile.  Reading the documentation this could be a profile family.  I can get my profile family like this:

 

FamilySymbol newFSP = (from elem in new FilteredElementCollector(doc)
                                        .OfClass(typeof(FamilySymbol))
                                       let type = elem as FamilySymbol
                                       where type.FamilyName == "Profile_HalfRound"
                                       select type).FirstOrDefault();

But i need a FamilySymbolProfile type (which inherits from SweepProfile).  How do i get a FamilySymbolProfile type reference from my profile family?

I have tried modifying the linq above (changing typeof etc) but without success.

0 Likes
Reply
Accepted solutions (2)
3,361 Views
13 Replies
Replies (13)

Revitalizer
Advisor
Advisor
Accepted solution

Hi Graham,

 

next step is to call this method:

 

FamilySymbolProfile Application.NewFamilySymbolProfile(FamilySymbol familySymbol)

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





jeremytammik
Autodesk
Autodesk

Dear Graham,

 

Have you looked at these old samples on The Building Coder?

 

New Sweep and References -- http://thebuildingcoder.typepad.com/blog/2009/08/new-sweep-and-references.html

Sweep PickPath Tolerance Criteria -- http://thebuildingcoder.typepad.com/blog/2012/10/sweep-pickpath-tolerance-criteria.html

 

Or are they too old to help?

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

grahamcook
Advocate
Advocate

Thank you Revitalizer.

 

doc.Application.Create.NewFamilySymbolProfile(newFS) done the trick.

 

Ideally though i would like to just modify the profile on an existing sweep like in the code below.  Although the code runs through with no errors it makes no changes to the sweep.  The profile property of ProfileSymbol does appear to be read / write but probably only in the context of NEW ProfileSymbols on NEW sweeps, not existing ones.  But now i know how to get a NewFamilySymbolProfile reference i can re-create the sweep (albiet having to re-creating the path contraints which is painful Smiley Sad)

 

 

// get the first sweep
Sweep sweep = (from elem in new FilteredElementCollector(doc)
                           .OfClass(typeof(Sweep))
                           let type = elem as Sweep
                           select type).FirstOrDefault();

// Get the new profile
FamilySymbol newFS = (from elem in new FilteredElementCollector(doc)
                                        .OfClass(typeof(FamilySymbol))
                                          let type = elem as FamilySymbol
                                          where type.Name == "Profile_HalfRound"
                                          select type).FirstOrDefault();


// set the new profile (but has no effect)
sweep.ProfileSymbol.Profile = newFS;
0 Likes

grahamcook
Advocate
Advocate

Thank you Jeremy.  I would say your articles are never never too old!  But in this case Revitaliser gave me the answer i was after.

0 Likes

Anonymous
Not applicable

Although it takes no effect to directly set the FamilySymbolProfile.Profile property, you can try to get a parameter of BuiltinParameter.PROFILE_FAM_TYPE  from the sweep element and set the id of the new familysymbol to this parameter. Wish this can help you

0 Likes

dirk.neethling
Advocate
Advocate

Hallo Jeremy,

 

where can I find a complete sweep example?

I need to draw a rubber seal in a groove. It's fairly straight-forward in terms of geometry, but I'm struggling to get going.

Regards, Dirk

0 Likes

jeremytammik
Autodesk
Autodesk

Dear Dirk,

 

Have you checked the Revit SDK samples?

 

Look at 

 

SDK/Samples/FamilyCreation/GenericModelCreation/CS/Command.cs

 

Otherwise, I can only repeat the pointers I already provided above:

 

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

dirk.neethling
Advocate
Advocate

Hello Jeremy,

 

I checked out your samples, the thing is I want to draw directly in the document, and not via a Family. So it seems that the utilities under

GeometryCreationUtilities would be useful. I am struggling along to get to a point where I can extrude a profile along an Arc. So I am working through your samples, in the hope of eventually stringing things together.

 

I am using this simple example, taken from your blog:

http://thebuildingcoder.typepad.com/blog/2015/07/intersect-solid-filter-avf-and-directshape-for-debu...

 

/// <summary>
/// Create and return a cube of
  /// side length d at the origin.
  /// </summary>
  static Solid CreateCube( double d )
  {
    return CreateRectangularPrism(
      XYZ.Zero, d, d, d );
  }

 

When I run CreateCube(2) or similar, nothing appears in the 3D view?

What am I doing wrong?

Regards, Dirk Neethling

0 Likes

grahamcook
Advocate
Advocate

Dirk

 

The example you are following will only create the solid in memory, and NOT in the Revit document.  You can only use this solid for intersection analysis, Boolean operations, etc.  See http://thebuildingcoder.typepad.com/blog/2012/09/sphere-creation-for-avf-and-filtering.html

 

Also, here is a link to creating solids, sweeps, extrusions in a FAMILY.  http://bim-g.blogspot.co.uk/2012/07/analyzing-sdk-samples_132.html#!/2012/07/analyzing-sdk-samples_1...

 

Unless the API now allows the creation of In-Place families, you may not be able to automate the sweep as you want.  I've googled it but can only find an old post from Jeremy from 2010 stating that in-place families are not supported, I cannot find anything more recent to the contrary - hope I'm wrong though Smiley Happy

 

Regards

 

Graham Cook

0 Likes

dirk.neethling
Advocate
Advocate

Hello Graham,

 

Revitalizer helped me solve the problem.

The solid object in memory can be inserted into the project like so:

 

solid = GeometryCreationUtilities.CreateExtrusionGeometry(loops, v, v.GetLength());

categoryId = new ElementId(BuiltInCategory.OST_GenericModel);

ds = DirectShape.CreateElement(doc, categoryId, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());

solids = new List<GeometryObject>() { solid };

ds.SetShape(solids);

ds.Name = "ExtrusionTest4";

 

Using Families in this case would be too much trouble.

Regards, Dirk

0 Likes

grahamcook
Advocate
Advocate

Hi Dirk.

 

Thanks for sharing.  That's good to know!

 

Graham

0 Likes

jeremytammik
Autodesk
Autodesk

I created a complete minimal sample add-in generating a FamilySymbolProfile from scratch to answer this subsequent related question:

 

https://forums.autodesk.com/t5/revit-api-forum/sweep-profile-from-family/m-p/7758601

 

Here is the direct link to the GitHub repository:

 

https://github.com/jeremytammik/NewFamilySymbolProfile

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

jeremytammik
Autodesk
Autodesk
Accepted solution

I 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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes