Can't create Sweep from FamilySymbolProfile.

Can't create Sweep from FamilySymbolProfile.

AndrewButenko
Advocate Advocate
1,977 Views
7 Replies
Message 1 of 8

Can't create Sweep from FamilySymbolProfile.

AndrewButenko
Advocate
Advocate

Hello All!

 

I try to create sweep with next code:

 

 'Get FamilySymbolProfile 
            Dim fsp As FamilySymbolProfile = GetSweepProfileFamily(doc, currentRetailingWallType.Profiles(0).Name)


            'Get family Metric Generic Model path
            Dim famTemplatePath As String = commandData.Application.Application.FamilyTemplatePath
            famTemplatePath = famTemplatePath.Substring(0, famTemplatePath.LastIndexOf("\")) + "\Family Templates\English"
            Dim pat As String = Path.Combine(famTemplatePath, "Metric Generic Model.rft")


            'Get family document  Metric Generic Model
            Dim fdoc As Document = commandData.Application.Application.NewFamilyDocument(pat)


            Dim sweep As Sweep = Nothing


            Dim fTr As New Transaction(fdoc, "CreateSweep")
            fTr.Start()

            Dim plane As Plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, New XYZ(0, 0, 0))
            Dim sketchplane1 As SketchPlane = SketchPlane.Create(fdoc, plane)

            Dim pnt4 As New XYZ(10, 0, 0)
            Dim pnt5 As New XYZ(0, 10, 0)
            Dim curve As Curve = Line.CreateBound(pnt4, pnt5)

            Dim curves As New CurveArray()
            curves.Append(curve)

            ' create a solid sweep
            sweep = fdoc.FamilyCreate.NewSweep(True, curves, sketchplane1, fsp, 0, ProfilePlaneLocation.Start)

            fTr.Commit()

 

But I get error: "Autodesk.Revit.Exceptions.ArgumentException: "One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument."

 

Anybody help me?

0 Likes
Accepted solutions (1)
1,978 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

Before you create the sweep programmatically, generate the model curves that you plan to use and perform the sweep generation manually in the end user interface. That will give you more precise information on any problems encountered:

 

http://thebuildingcoder.typepad.com/blog/2009/07/debug-geometric-form-creation.html

 



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

0 Likes
Message 3 of 8

FAIR59
Advisor
Advisor

You find the profile in a document (doc) and try to use it in another document (fdoc). That will not work. Copy the profile-family to the fdoc.

0 Likes
Message 4 of 8

AndrewButenko
Advocate
Advocate
Accepted solution

I figure it. 

 

Instead of using:

 

sweep = fdoc.FamilyCreate.NewSweep (True, curves, sketchplane1, fsp, 0, ProfilePlaneLocation.Start)

 

where fsp is FamilySymbolProfile,

 

I get profile geometry from a family document to a swp variable:

 

Dim ffilter As ElementClassFilter = New ElementClassFilter (GetType (CurveElement))
Dim fcollector As FilteredElementCollector = New FilteredElementCollector (fdoc)
fcollector.WherePasses (ffilter)

Dim curves As List (Of DetailCurve) = fcollector.Cast (Of DetailCurve) .ToList

Dim caa As New CurveArrArray
Dim ca As New CurveArray

For Each c As Detail Curve In curves
ca.Append (c.GeometryCurve)
Next

caa.append (ca)

Dim swp As SweepProfile = doc.Application.Create.NewCurveLoopsProfile (caa)

 

and call:

sweep = fdoc.FamilyCreate.NewSweep (True, curves, sketchplane1, swp, 0, ProfilePlaneLocation.Start)
0 Likes
Message 5 of 8

Dale.Bartlett
Collaborator
Collaborator

Thanks for posting your solution Andrew. All the examples I found for creating sweeps use a newly generated profile. All very well for simple examples, but not useful if you have an existing complex profile. Very much appreciated. Dale




______________
Yes, I'm Satoshi.
0 Likes
Message 6 of 8

Dale.Bartlett
Collaborator
Collaborator

PS here is my C# conversion:

public static SweepProfile CreateSweepProfileFromProfile(RvtDoc pDoc)
{
ElementClassFilter ffilter = new ElementClassFilter(typeof(CurveElement));
FilteredElementCollector fcollector = new FilteredElementCollector(pDoc);
fcollector.WherePasses(ffilter);
List<DetailCurve> curves = fcollector.Cast<DetailCurve>().ToList();
CurveArrArray caa = new CurveArrArray();
CurveArray ca = new CurveArray();
foreach (DetailCurve c in curves)
ca.Append(c.GeometryCurve);
caa.Append(ca);
SweepProfile swp = pDoc.Application.Create.NewCurveLoopsProfile(caa);
// usage
// sweep = fdoc.FamilyCreate.NewSweep(true, curves, sketchplane1, swp, 0, ProfilePlaneLocation.Start);
return swp;
}



______________
Yes, I'm Satoshi.
0 Likes
Message 7 of 8

jeremytammik
Autodesk
Autodesk

I've looked at your two answers several times over now and am still very confused by them.

 

The sweep creation requires a sweep path and a sweep profile.

 

The path is the second input argument, the profile the fourth.

 

You pass in `curves` as the second and `swp` as the fourth.

 

However, you also use `curves` to generate `swp`.

 

Isn't that awfully weird? Why are you using the sweep profile to define the sweep path, and vice versa? 

 

Should not the path and the profile be two completely separate things?

 

Sorry if I am misunderstanding something completely...

 

Thank you for any clarification!

  

Here is an example from The Building Coder samples that I understand better, by the way:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

Best regards,

 

Jeremy

 

 



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

0 Likes
Message 8 of 8

jeremytammik
Autodesk
Autodesk

Taking another look at this, I not that this issue (or very similar ones) have been discussed repeatedly here in the past and the results summarised by The Building Coder, in case that is of any use:

 

https://thebuildingcoder.typepad.com/blog/2018/02/newfamilysymbolprofile-sample-add-in.html

 



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

0 Likes