Orientation of Sketchplane when creating NewSweep based on Arc in Family Document

Orientation of Sketchplane when creating NewSweep based on Arc in Family Document

AH_Yafim
Enthusiast Enthusiast
1,267 Views
7 Replies
Message 1 of 8

Orientation of Sketchplane when creating NewSweep based on Arc in Family Document

AH_Yafim
Enthusiast
Enthusiast

Hi,

I'm dynamically creating some sweeps based on paths. The sweeps are getting created and loaded into the main revit Document as families.

 

For straight lines, this works fine, but for an Arc, something weird is happening and I can't figure it out. I'm almost sure it has something to do with the input for the SketchPlane in the NewSweep() method, but I haven't been able to solve what the right plane orientation is or how to built it. I tried using the XDirection and YDirection of the Arc object, and also looked at this post:

https://forums.autodesk.com/t5/revit-api-forum/error-using-familycreate-newsweep/td-p/6941973 

 

but it didn't help to use the same method as in the post for creating the SketchPlane.

So far the code is:

 

arc_plane = Plane.CreateByNormalAndOrigin( XYZ.BasisZ, XYZ.Zero)
			arc_sketchPlane = SketchPlane.Create(fdoc, arc_plane)
			
sweep = fdoc.FamilyCreate.NewSweep( True, arc_path, arc_sketchPlane,
                                    profile, 0, ProfilePlaneLocation.Start)

return sweep

 

 

Everything seems to be in order but the SketchPlane, and this is the result I get, where the arc is created but it is skewed on the XY plane:

(attached below are images from a 3D View and a Plan view, with marks as to the desired result in red)

 

 

 

 

Accepted solutions (1)
1,268 Views
7 Replies
Replies (7)
Message 2 of 8

jeremy_tammik
Alumni
Alumni

It is unclear what result you desire. Is your target shape a vertical face with an arc-shaped footprint? In other words, does it look like a rectangle in the side view and an arc in plan? In that case, I think your input plane for the sweep operation needs to be vertical and perpendicular to the arc tangent at its start point.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 8

jeremy_tammik
Alumni
Alumni
isSolid
Type: System Boolean
Indicates if the Sweep is Solid or Void.
 

I guess true is OK in your case.

 

path
Type: Autodesk.Revit.DB CurveArray
The path of the sweep. The path should be 2D, where all input curves lie in one plane, and the curves are not required to reference existing geometry.
 

Is your variable arc_path an array of curves?

 

pathPlane
Type: Autodesk.Revit.DB SketchPlane
The sketch plane for the path. Use this when you want to create a 2D path that resides on an existing planar face. Optional, can be a null reference ( Nothing in Visual Basic) for 3D paths or for 2D paths where the path should not reference an existing face.
 

This can also be null. Since your arc already defines a plane, why not just leave is as null?

 

profile
Type: Autodesk.Revit.DB SweepProfile
The profile of the newly created Sweep. This may contain more than one curve loop or a profile family. The profile must lie in the XY plane, and it will be transformed to the profile plane automatically. Each loop must be a fully closed curve loop and the loops must not intersect. The loop can be a unbound circle or ellipse, but its geometry will be split in two in order to satisfy requirements for sketches used in extrusions.
 

This seems to just be a single line in your case?

 

profileLocationCurveIndex
Type: System Int32
The index of the path curves. The curve upon which the profile plane will be determined.
 

0 seems OK.

 

profilePlaneLocation
Type: Autodesk.Revit.DB ProfilePlaneLocation
The location on the profileLocationCurve where the profile plane will be determined.
 

Start also seems fine.

 

So, I would suggest to start by just providing null for the sketch plane.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 8

AH_Yafim
Enthusiast
Enthusiast

Hi @jeremy_tammik  thanks for the reply.

Indeed I'm trying to create a sweep that looks like a rectangle in the side view and an arc in plan. Sorry if that wasn't so clear from the image.

 

I tried null as you suggested but that isn't a valid input for the SketchPlane. More precisely, I'm writing in python so I tried "None" which is the null equivalent, but an error says that None is an invalid input, even though the documentation you quotes says it can be... strange.

 

I think the issue is the orientation of the SketchPlane, because with straight lines it works and with an arc it doesn't. Your suggestion that "input plane for the sweep operation needs to be vertical and perpendicular to the arc tangent at its start point" sounds right to me.

 

Do you know of a way to ensure the perpendicularity of a plane using a vector only? Is it simply:

 

arc_plane = Plane.CreateByNormalAndOrigin( tangent_vector, XYZ.Zero)

 

 ?

 

Thanks

0 Likes
Message 5 of 8

AH_Yafim
Enthusiast
Enthusiast

As another thought, the documentation says "can be a null reference", perhaps I can create some "null" SketchPlane and give that as input, instead of inputting an actual "null" ?

0 Likes
Message 6 of 8

AH_Yafim
Enthusiast
Enthusiast
Accepted solution

@jeremy_tammik 

In the end the issue was that for the profile definition I was using some vectors that I shouldn't have, and that was throwing the sweep off due to the arcs and line segment length.

 

I just used simpler and more 'manual' profile coordinates. Now it works fine.

 

Thanks for the suggestions 🙂

0 Likes
Message 7 of 8

AH_Yafim
Enthusiast
Enthusiast

@jeremy_tammik 

 

As a follow-up note, do you know if there's a difference in this method between 2019 and 2021?

Because the script works in 2019 but in 2021 it says that "one of the conditions was not satisfied", with regard to the NewSweep method, which isn't very informative...

 

Any ideas?

Message 8 of 8

jeremy_tammik
Alumni
Alumni

I am not aware of any such changes. However, sometimes additional internal checks are implemented and added.

 

Any ideas? Yes, you might try to reproduce the problem manually through the end user interface to receive a more informative error message, as described in debugging form creation:

 

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

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes