本文整理汇总了C#中FamilyInstance.get_Geometry方法的典型用法代码示例。如果您正苦于以下问题:C# FamilyInstance.get_Geometry方法的具体用法?C# FamilyInstance.get_Geometry怎么用?C# FamilyInstance.get_Geometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FamilyInstance
的用法示例。
在下文中一共展示了FamilyInstance.get_Geometry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWindowDirection
/// <summary>
/// Obtains the facing direction of the window.
/// </summary>
/// <param name="wall">The window.</param>
/// <returns>A normalized XYZ direction vector.</returns>
protected XYZ GetWindowDirection(FamilyInstance window)
{
Options options = new Options();
// Extract the geometry of the window.
GeometryElement geomElem = window.get_Geometry(options);
foreach (GeometryObject geomObj in geomElem.Objects)
{
// We expect there to be one main Instance in each window. Ignore the rest of the geometry.
GeometryInstance instance = geomObj as GeometryInstance;
if (instance != null)
{
// Obtain the Instance's transform and the nominal facing direction (Y-direction).
Transform t = instance.Transform;
XYZ facingDirection = t.BasisY;
// If the window is flipped in one direction, but not the other, the transform is left handed.
// The Y direction needs to be reversed to obtain the facing direction.
if ((window.FacingFlipped && !window.HandFlipped) || (!window.FacingFlipped && window.HandFlipped))
facingDirection = -facingDirection;
// Because the need to perform this operation on instances is so common,
// the Revit API exposes this calculation directly as the FacingOrientation property
// as shown in GetWindowDirectionAlternate()
return facingDirection;
}
}
return XYZ.BasisZ;
}
示例2: ExportFamilyInstanceAsMappedItem
//.........这里部分代码省略.........
rangeOffset = new XYZ(rangeOffset.X, rangeOffset.Y, levelInfo.Elevation + nonStoryLevelOffset);
}
}
}
rangeOffset += extraOffset;
trf.Origin = rangeOffset;
}
IFCAnyHandle dummyPlacement = null;
if (doorWindowInfo != null)
{
doorWindowTrf = ExporterIFCUtils.GetTransformForDoorOrWindow(familyInstance, familySymbol, doorWindowInfo);
}
else
{
dummyPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, ExporterUtil.CreateAxis2Placement3D(file));
extraParams.SetLocalPlacement(dummyPlacement);
}
bool needToCreate2d = ExporterCacheManager.ExportOptionsCache.ExportAnnotations;
bool needToCreate3d = IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRepresentation);
if (needToCreate2d || needToCreate3d)
{
using (IFCTransformSetter trfSetter = IFCTransformSetter.Create())
{
if (doorWindowInfo != null)
{
trfSetter.Initialize(exporterIFC, doorWindowTrf);
}
GeometryElement exportGeometry =
useInstanceGeometry ? familyInstance.get_Geometry(options) : familySymbol.get_Geometry(options);
if (exportGeometry == null)
return;
if (needToCreate3d)
{
SolidMeshGeometryInfo solidMeshCapsule = null;
if (range == null)
{
solidMeshCapsule = GeometryUtil.GetSolidMeshGeometry(exportGeometry, Transform.Identity);
}
else
{
solidMeshCapsule = GeometryUtil.GetClippedSolidMeshGeometry(exportGeometry, range);
}
IList<Solid> solids = solidMeshCapsule.GetSolids();
IList<Mesh> polyMeshes = solidMeshCapsule.GetMeshes();
if (range != null && (solids.Count == 0 && polyMeshes.Count == 0))
return; // no proper split geometry
geomObjects = FamilyExporterUtil.RemoveSolidsAndMeshesSetToDontExport(doc, exporterIFC, solids, polyMeshes);
if (geomObjects.Count == 0 && (solids.Count > 0 || polyMeshes.Count > 0))
return;
bool tryToExportAsExtrusion = (!exporterIFC.ExportAs2x2 || (exportType == IFCExportType.ExportColumnType));
if (exportType == IFCExportType.ExportColumnType)
{
extraParams.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
示例3: GeometrySupport
/// <summary>
/// constructor
/// </summary>
/// <param name="element">the host object, must be family instance</param>
/// <param name="geoOptions">the geometry option</param>
public GeometrySupport(FamilyInstance element, Options geoOptions)
{
// get the geometry element of the selected element
Autodesk.Revit.DB.GeometryElement geoElement = element.get_Geometry(new Options());
if (null == geoElement || 0 == geoElement.Objects.Size)
{
throw new Exception("Can't get the geometry of selected element.");
}
AnalyticalModel aModel = element.GetAnalyticalModel();
if (aModel == null)
{
throw new Exception("The selected FamilyInstance don't have AnalyticalModel.");
}
AnalyticalModelSweptProfile swProfile = aModel.GetSweptProfile();
if (swProfile == null || !(swProfile.GetDrivingCurve() is Line))
{
throw new Exception("The selected element driving curve is not a line.");
}
// get the driving path and vector of the beam or column
Line line = swProfile.GetDrivingCurve() as Line;
if (null != line)
{
m_drivingLine = line; // driving path
m_drivingVector = GeomUtil.SubXYZ(line.get_EndPoint(1), line.get_EndPoint(0));
}
//get the geometry object
foreach (GeometryObject geoObject in geoElement.Objects)
{
//get the geometry instance which contain the geometry information
GeoInstance instance = geoObject as GeoInstance;
if (null != instance)
{
foreach (GeometryObject o in instance.SymbolGeometry.Objects)
{
// get the solid of beam of column
Solid solid = o as Solid;
// do some checks.
if (null == solid)
{
continue;
}
if (0 == solid.Faces.Size || 0 == solid.Edges.Size)
{
continue;
}
m_solid = solid;
//get the transform value of instance
m_transform = instance.Transform;
// Get the swept profile curves information
if (!GetSweptProfile(solid))
{
throw new Exception("Can't get the swept profile curves.");
}
break;
}
}
}
// do some checks about profile curves information
if (null == m_edges)
{
throw new Exception("Can't get the geometry edge information.");
}
if (4 != m_points.Count)
{
throw new Exception("The sample only work for rectangular beams or columns.");
}
}
示例4: GetSpecialFamilyReference
public static Reference GetSpecialFamilyReference(
FamilyInstance inst,
SpecialReferenceType refType)
{
Reference indexRef = null;
int idx = (int) refType;
if( inst != null )
{
Document dbDoc = inst.Document;
Options geomOptions = dbDoc.Application.Create
.NewGeometryOptions();
if( geomOptions != null )
{
geomOptions.ComputeReferences = true;
geomOptions.DetailLevel = ViewDetailLevel.Undefined;
geomOptions.IncludeNonVisibleObjects = true;
}
GeometryElement gElement = inst.get_Geometry(
geomOptions );
GeometryInstance gInst = gElement.First()
as GeometryInstance;
String sampleStableRef = null;
if( gInst != null )
{
GeometryElement gSymbol = gInst
.GetSymbolGeometry();
if( gSymbol != null )
{
foreach( GeometryObject geomObj in gSymbol )
{
if( geomObj is Solid )
{
Solid solid = geomObj as Solid;
if( solid.Faces.Size > 0 )
{
Face face = solid.Faces.get_Item( 0 );
sampleStableRef = face.Reference
.ConvertToStableRepresentation(
dbDoc );
break;
}
}
else if( geomObj is Curve )
{
Curve curve = geomObj as Curve;
sampleStableRef = curve.Reference
.ConvertToStableRepresentation( dbDoc );
break;
}
else if( geomObj is Point )
{
Point point = geomObj as Point;
sampleStableRef = point.Reference
.ConvertToStableRepresentation( dbDoc );
break;
}
}
}
if( sampleStableRef != null )
{
String[] refTokens = sampleStableRef.Split(
new char[] { ':' } );
String customStableRef = refTokens[0] + ":"
+ refTokens[1] + ":" + refTokens[2] + ":"
+ refTokens[3] + ":" + idx.ToString();
indexRef = Reference
.ParseFromStableRepresentation(
dbDoc, customStableRef );
GeometryObject geoObj = inst
.GetGeometryObjectFromReference(
indexRef );
if( geoObj != null )
{
String finalToken = "";
if( geoObj is Edge )
{
finalToken = ":LINEAR";
}
//.........这里部分代码省略.........
示例5: GetFamilyInstancePointReference
/// <summary>
/// Retrieve the given family instance's
/// non-visible geometry point reference.
/// </summary>
static Reference GetFamilyInstancePointReference(
FamilyInstance fi)
{
return fi.get_Geometry( _opt )
.OfType<Point>()
.Select<Point, Reference>( x => x.Reference )
.FirstOrDefault();
}
示例6: ExportFamilyInstanceAsMappedItem
//.........这里部分代码省略.........
}
}
rangeOffset += extraOffset;
trf.Origin = rangeOffset;
}
Transform doorWindowTrf = Transform.Identity;
IFCAnyHandle dummyPlacement = IFCAnyHandle.Create();
if (doorWindowInfo != null)
{
doorWindowTrf = ExporterIFCUtils.GetTransformForDoorOrWindow(familyInstance, familySymbol, doorWindowInfo);
}
else
{
dummyPlacement = file.CreateLocalPlacement(IFCAnyHandle.Create(), file.CreateAxis2Placement3D());
extraParams.SetLocalPlacement(dummyPlacement);
}
bool needToCreate2d = (!exporterIFC.ExportAs2x2);
bool needToCreate3d = (!bodyRepresentation.HasValue);
if (needToCreate2d || needToCreate3d)
{
using (IFCTransformSetter trfSetter = IFCTransformSetter.Create())
{
if (doorWindowInfo != null)
{
trfSetter.Initialize(exporterIFC, doorWindowTrf);
}
Options options = new Options();
GeometryElement exportGeometry =
useInstanceGeometry ? familyInstance.get_Geometry(options) : familySymbol.get_Geometry(options);
if (exportGeometry == null)
return;
if (needToCreate3d)
{
IFCSolidMeshGeometryInfo solidMeshInfo;
if (range == null)
solidMeshInfo = ExporterIFCUtils.GetSolidMeshGeometry(exporterIFC, exportGeometry, Transform.Identity);
else
solidMeshInfo = ExporterIFCUtils.GetClippedSolidMeshGeometry(exporterIFC, range, exportGeometry);
IList<Solid> solids = solidMeshInfo.GetSolids();
IList<Mesh> polyMeshes = solidMeshInfo.GetMeshes();
bool tryToExportAsExtrusion = (!exporterIFC.ExportAs2x2 || (exportType == IFCExportType.ExportColumnType));
if (exportType == IFCExportType.ExportColumnType)
{
extraParams.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
}
else
{
extraParams.PossibleExtrusionAxes = IFCExtrusionAxes.TryXYZ;
}
if (solids.Count > 0 || polyMeshes.Count > 0)
{
bodyRepresentation = BodyExporter.ExportBody(familyInstance.Document.Application, exporterIFC, categoryId, solids, polyMeshes,
tryToExportAsExtrusion, extraParams);
typeInfo.MaterialId = BodyExporter.GetBestMaterialIdForGeometry(solids, polyMeshes);
}
示例7: ExportFamilyInstanceAsMappedItem
/// <summary>
/// Exports a family instance as a mapped item.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="familyInstance">The family instance to be exported.</param>
/// <param name="exportType">The export type.</param>
/// <param name="ifcEnumType">The string value represents the IFC type.</param>
/// <param name="wrapper">The ProductWrapper.</param>
/// <param name="overrideLevelId">The level id.</param>
/// <param name="range">The range of this family instance to be exported.</param>
public static void ExportFamilyInstanceAsMappedItem(ExporterIFC exporterIFC,
FamilyInstance familyInstance, IFCExportType exportType, string ifcEnumType,
ProductWrapper wrapper, ElementId overrideLevelId, IFCRange range, IFCAnyHandle parentLocalPlacement)
{
bool exportParts = PartExporter.CanExportParts(familyInstance);
bool isSplit = range != null;
if (exportParts && !PartExporter.CanExportElementInPartExport(familyInstance, isSplit ? overrideLevelId : familyInstance.Level.Id, isSplit))
return;
Document doc = familyInstance.Document;
IFCFile file = exporterIFC.GetFile();
// The "originalFamilySymbol" has the right geometry, but should be used as little as possible.
FamilySymbol originalFamilySymbol = ExporterIFCUtils.GetOriginalSymbol(familyInstance);
FamilySymbol familySymbol = familyInstance.Symbol;
if (originalFamilySymbol == null || familySymbol == null)
return;
ProductWrapper familyProductWrapper = ProductWrapper.Create(wrapper);
double scale = exporterIFC.LinearScale;
Options options = GeometryUtil.GetIFCExportGeometryOptions();
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
HostObject hostElement = familyInstance.Host as HostObject; //hostElement could be null
ElementId categoryId = CategoryUtil.GetSafeCategoryId(familySymbol);
//string emptyString = "";
string familyName = familySymbol.Name;
string revitObjectType = familyName;
// A Family Instance can have its own copy of geometry, or use the symbol's copy with a transform.
// The routine below tells us whether to use the Instance's copy or the Symbol's copy.
bool useInstanceGeometry = ExporterIFCUtils.UsesInstanceGeometry(familyInstance);
Transform trf = familyInstance.GetTransform();
using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
{
bool exportingDoor = (exportType == IFCExportType.ExportDoorType);
bool exportingWindow = (exportType == IFCExportType.ExportWindowType);
bool exportingHostParts = PartExporter.CanExportParts(hostElement);
HostObject hostElementForDoorWindow = exportingHostParts ? null : hostElement;
// Extra information if we are exporting a door or a window.
IFCDoorWindowInfo doorWindowInfo = null;
if (exportingDoor)
doorWindowInfo = IFCDoorWindowInfo.CreateDoorInfo(exporterIFC, familyInstance, originalFamilySymbol, hostElementForDoorWindow, overrideLevelId, trf);
else if (exportingWindow)
doorWindowInfo = IFCDoorWindowInfo.CreateWindowInfo(exporterIFC, familyInstance, originalFamilySymbol, hostElementForDoorWindow, overrideLevelId, trf);
bool ignoreDoorWindowOpening = ((exportingDoor || exportingWindow) && exportingHostParts);
FamilyTypeInfo typeInfo = new FamilyTypeInfo();
bool flipped = doorWindowInfo != null ? doorWindowInfo.IsSymbolFlipped : false;
FamilyTypeInfo currentTypeInfo = ExporterCacheManager.TypeObjectsCache.Find(originalFamilySymbol.Id, flipped);
bool found = currentTypeInfo.IsValid();
Family family = familySymbol.Family;
IList<GeometryObject> geomObjects = new List<GeometryObject>();
Transform offsetTransform = null;
Transform doorWindowTrf = Transform.Identity;
// We will create a new mapped type if:
// 1. We are exporting part of a column or in-place wall (range != null), OR
// 2. We are using the instance's copy of the geometry (that it, it has unique geometry), OR
// 3. We haven't already created the type.
bool creatingType = ((range != null) || useInstanceGeometry || !found);
if (creatingType)
{
IFCAnyHandle bodyRepresentation = null;
IFCAnyHandle planRepresentation = null;
IFCAnyHandle dummyPlacement = null;
if (doorWindowInfo != null)
{
doorWindowTrf = ExporterIFCUtils.GetTransformForDoorOrWindow(familyInstance, originalFamilySymbol, doorWindowInfo);
}
else
{
dummyPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, ExporterUtil.CreateAxis2Placement3D(file));
extraParams.SetLocalPlacement(dummyPlacement);
}
bool needToCreate2d = ExporterCacheManager.ExportOptionsCache.ExportAnnotations;
GeometryElement exportGeometry =
useInstanceGeometry ? familyInstance.get_Geometry(options) : originalFamilySymbol.get_Geometry(options);
if (!exportParts)
//.........这里部分代码省略.........
示例8: GetMassFaceArray
/// <summary>
/// get the faces of the mass
/// </summary>
/// <param name="mass">
/// the source mass
/// </param>
/// <returns>
/// the faces of the mass
/// </returns>
private FaceArray GetMassFaceArray(FamilyInstance mass)
{
// Obtain the gemotry information of the mass
Autodesk.Revit.DB.Options opt = m_mydocument.CommandData.Application.Application.Create.NewGeometryOptions();
opt.DetailLevel = Autodesk.Revit.DB.DetailLevels.Fine;
opt.ComputeReferences = true;
Autodesk.Revit.DB.GeometryElement geoElement = null;
try
{
geoElement = mass.get_Geometry(opt);
}
catch (System.Exception)
{
return null;
}
if (null == geoElement)
{
return null;
}
GeometryObjectArray objectarray = geoElement.Objects;
foreach (GeometryObject obj in objectarray)
{
Solid solid = obj as Solid;
if (null != solid &&
null != solid.Faces &&
0 != solid.Faces.Size)
{
return solid.Faces;
}
}
return null;
}