Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: ynapeu

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

EESignature

(Not an Autodesk Employee)