CreateViaOffset
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I hope some one can help as I have been going round in circles with this for some time. I am trying to create a CurveLoop CreateViaOffset
I have looked at most if not all of the posts on this subject and every time i think i have a working solution either through utilising those solutions posted or my own and i constantly obtain an error of one kind or another.
My Code for the CurveLoop is
public void CropAroundRoom(Autodesk.Revit.DB.Architecture.Room room, Autodesk.Revit.DB.View view)
{
if (view != null)
{
IList<IList<Autodesk.Revit.DB.BoundarySegment>> segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions());
if (null != segments)
{
foreach (IList<Autodesk.Revit.DB.BoundarySegment> segmentList in segments)
{
CurveLoop loop = new CurveLoop();
foreach (Autodesk.Revit.DB.BoundarySegment boundarySegment in segmentList)
{
List<XYZ> points = boundarySegment.GetCurve().Tessellate().ToList();
for(int ip=0; ip< points.Count-1; ip++)
{
Line l = Line.CreateBound(points[ip],points[ip+1]);
loop.Append(l);
}
}
ViewCropRegionShapeManager vcrShapeMgr = view.GetCropRegionShapeManager();
bool cropValid = vcrShapeMgr.IsCropRegionShapeValid(loop);
if (cropValid)
{
vcrShapeMgr.SetCropShape(loop);
break;
}
}
}
}
}I have also utilised the BuidingCoder GetCurveNormal and from examining the returned XYZ they were (1,0,0), (0,1,0),(0,1,0),(-1,0,0) and (0,-1,0).
The help Syntax for CreateViaOffset
public static CurveLoop CreateViaOffset(CurveLoop original,double offsetDist,XYZ normal)
Therefore I passed in my loop created above, a double value of 2.0 and one of the normal values obtained from GetCurveNormal and unfortunately an error.
I then thought that I had misunderstood an tried passing a normal for each curve of the curve loop. Error.
Ultimately my objective is to create a new CurveLoop some fixed distance beyond the room.
If at all possible I would also like to be able to create alternate offsets for each face even if that means utilising an alternate to CreateViaOffset.
Any help would be much appreciated.