- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
i want the faces of a SurfaceBody.
but the Function CalculateFacets creates a crash.
I have checked the oBodybox the have Vertices and so on.
Is there some trick to get the Facets?
public SurfaceBody tempTest(Inventor.Application oApp)
{
TransientGeometry oTransGeom = oApp.TransientGeometry;
TransientBRep oTransientBRep = oApp.TransientBRep;
Box box1 = oApp.TransientGeometry.CreateBox();
box1.MinPoint = (oApp.TransientGeometry.CreatePoint(0, 0, 0));
box1.MaxPoint = (oApp.TransientGeometry.CreatePoint(30, 30, 40));
SurfaceBody oBodybox = oTransientBRep.CreateSolidBlock(box1);
int count1 = 0;
int facecount1 = 0;
double[] Vertex1 = { };
double[] Normalvect1 = { };
int[] vertexindeces1 = { };
try
{
oBodybox.CalculateFacets(0.001, out count1, out facecount1, out Vertex1, out Normalvect1, out vertexindeces1);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
return (oBodybox);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What you are doing in code is creating an imaginary box using Transient geometry and transient Brep, are you looking for a real face of a surface body and or the transient one?
If you can explain, exactly what you are trying to achieve, it will be helpful.
Regards,
Dutt Thakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I will create a surfacebody, with diffrent operation, BOX, DoBoolean and so on.
Than i want the faces of this Object.
I have tested, i get the VOlume of the Body but not the Faces.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If all you want is the Faces of the SurfaceBody object, the SurfaceBody object has a Property called Faces that should give you what you want.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE'
.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Also, I believe @ynapeu's posted code was in C#, and I believe this would be the iLogic equivalent of it:
(minus the Sub Main ... End Sub portion)
Sub Main
Dim oBody As SurfaceBody = tempTest(ThisApplication)
End Sub
Public Function tempTest(oApp As Inventor.Application) As SurfaceBody
Dim oTransGeom As TransientGeometry = oApp.TransientGeometry
Dim oTransientBRep As TransientBRep = oApp.TransientBRep
Dim box1 As Box = oApp.TransientGeometry.CreateBox()
box1.MinPoint = (oApp.TransientGeometry.CreatePoint(0, 0, 0))
box1.MaxPoint = (oApp.TransientGeometry.CreatePoint(30, 30, 40))
Dim oBodybox As SurfaceBody = oTransientBRep.CreateSolidBlock(box1)
Dim count1 As Integer = 0
Dim facecount1 As Integer = 0
Dim Vertex1() As Double = { }
Dim Normalvect1() As Double = { }
Dim vertexindeces1() As Integer = { }
Try
oBodybox.CalculateFacets(0.001, count1, facecount1, Vertex1, Normalvect1, vertexindeces1)
Catch E As Exception
MessageBox.Show(E.ToString())
End Try
Return oBodybox
End Function
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Yes, i think this schould do the same thing.
In C# the CalculatesFacet Function crashes.
I need the Trianglefaces of the Surfacebody.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I attempted this using regular iLogic and the natural process of extruding a new solid body, then attempting to get its 'facets' using that same function, but have had no success with this route yet either. Just in case others want to continue the research, I will post what I've got so far. I've honestly never attempted to retrieve or use 'facet' data before, so maybe I'm missing something that someone else will notice and pick-up on.
Here's what I have so far (iLogic):
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oSketch As PlanarSketch = oPDef.Sketches.Add(oPDef.WorkPlanes.Item(2)) 'XZ Plane
Dim oCorner1 As Point2d = oTG.CreatePoint2d(0, 0)
Dim oCorner2 As Point2d = oTG.CreatePoint2d(30,30)
oSketch.SketchLines.AddAsTwoPointRectangle(oCorner1, oCorner2)
Dim oProfile As Inventor.Profile = oSketch.Profiles.AddForSolid
Dim oExtDef As ExtrudeDefinition = oPDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kNewBodyOperation)
oExtDef.SetDistanceExtent(40, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
Dim oExt As ExtrudeFeature = oPDef.Features.ExtrudeFeatures.Add(oExtDef)
Dim oBody As SurfaceBody = oExt.SurfaceBodies.Item(1)
Dim oVCount As Integer
Dim oFacetCount As Integer
Dim oVCoords() As Double
Dim oNormVectors() As Double
Dim oVIndices() As Integer
Try
oBody.CalculateFacets(0.01, oVCount, oFacetCount, oVCoords, oNormVectors, oVIndices)
Catch oEx As Exception
MsgBox("Error Message:" & vbCrLf & _
oEx.Message & vbCrLf & vbCrLf & _
"StackTrace:" & vbCrLf & _
oEx.StackTrace & vbCrLf & vbCrLf & _
"Source:" & vbCrLf & _
oEx.Source, vbOKOnly + vbExclamation, "Title")
'delete the Extrusion feature, its source sketch, and all its dependants
oExt.Delete(False, False, False)
End Try
End Sub
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Many Thanks.
Your Works fine.
Restquestiuon, why crashes the original cose?