Random numbering of faces after SplitFaces()?

Random numbering of faces after SplitFaces()?

Anonymous
Not applicable
466 Views
2 Replies
Message 1 of 3

Random numbering of faces after SplitFaces()?

Anonymous
Not applicable

Hello! I'm trying to create a surface model to use for FEM in Nastran-In-CAD. For that reason I'm splitting a surface body into several different faces to apply loads on. I want to automate this using Nastran's iLogic functionality.

 

https://knowledge.autodesk.com/support/nastran-in-cad/learn-explore/caas/CloudHelp/cloudhelp/2019/EN...

(Nastran-In-CAD iLogic documentation)

 

When using the Nastran iLogic commands you need to give the ID of the entity (in my case the ID of the face). The problem is that the numbering of faces seems to be random after performing SplitFaces(), so I can't tell in advance what ID a face has.

 

Here is the iLogic code I am running:

' Set a reference to the Inventor application
Dim _invApp As Inventor.Application
_invApp = ThisApplication

' Create a new part document
Dim oDoc As PartDocument
oDoc = _invApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, _invApp.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject))

' Set a reference to the component definition
Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oDoc.ComponentDefinition

' Set a reference to the transient geometry
Dim oTG As TransientGeometry = _invApp.TransientGeometry


' --- Sketch and extrude a half cylinder ---
Dim oSketch As PlanarSketch
Dim oArc As SketchArc

' Create a center point.
Dim oCenter As Point2d
oCenter = oTG.CreatePoint2d(0, 0)

' Create a new sketch
oSketch = oPartCompDef.Sketches.Add(oPartCompDef.WorkPlanes.Item(3))           		' Add a sketch on workplane 3 (the x-y plane)
oArc = oSketch.SketchArcs.AddByCenterStartSweepAngle(oCenter, 100, 0, Math.PI)     	' Add a Arc to the sketch, input: centerpoint, radius in cm, sweep angle in radians
Dim oProfile As Profile
oProfile = oSketch.Profiles.AddForSurface   ' Store the sketch as a profile (to use for extrude)

' Define the extrusion.  
Dim oExtrudeDef As ExtrudeDefinition
Dim Operation As PartFeatureOperationEnum = PartFeatureOperationEnum.kSurfaceOperation                  ' Surface extrusion
oExtrudeDef = oPartCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, Operation)        ' Profile to extrude and what type of operation.
Call oExtrudeDef.SetDistanceExtent(300, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)     	' Set length of extrude (cm) and the direction

' Create the extrusion
Dim oExtrude As ExtrudeFeature
oExtrude = oPartCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)   ' Use the oExtrudeDef to create the extrude


' --- Access the surface body of the extrude ---
Dim oSurfaceBody As SurfaceBody
oSurfaceBody = oExtrude.SurfaceBodies.Item(1)


' --- Create two horizontal workplanes ---
Dim oPlane1 As WorkPlane
oPlane1 = oPartCompDef.WorkPlanes.AddByPlaneAndOffset(oPartCompDef.WorkPlanes.Item(3), 100)
Dim oPlane2 As WorkPlane
oPlane2 = oPartCompDef.WorkPlanes.AddByPlaneAndOffset(oPartCompDef.WorkPlanes.Item(3), 200)

' --- Create two vertical workplanes ---
Dim oPlane3 As WorkPlane
oPlane3 = oPartCompDef.WorkPlanes.AddByLinePlaneAndAngle(oPartCompDef.WorkAxes.Item(3), oPartCompDef.WorkPlanes.Item(2), 50 * Math.PI / 180)
Dim oPlane4 As WorkPlane
oPlane4 = oPartCompDef.WorkPlanes.AddByLinePlaneAndAngle(oPartCompDef.WorkAxes.Item(3), oPartCompDef.WorkPlanes.Item(2), 130 * Math.PI / 180)


' --- Split the surface body using the horizontal planes ---
Dim oSplitFeature1 As SplitFeature
oSplitFeature1 = oPartCompDef.Features.SplitFeatures.SplitFaces(oPlane1, True, oSurfaceBody)
Dim oSplitFeature2 As SplitFeature
oSplitFeature2 = oPartCompDef.Features.SplitFeatures.SplitFaces(oPlane2, True, oSurfaceBody)


' --- Split the surface body using the vertical planes ---
Dim oSplitFeature3 As SplitFeature
oSplitFeature3 = oPartCompDef.Features.SplitFeatures.SplitFaces(oPlane3, True, oSurfaceBody)
Dim oSplitFeature4 As SplitFeature
oSplitFeature4 = oPartCompDef.Features.SplitFeatures.SplitFaces(oPlane4, True, oSurfaceBody)


oDoc.ObjectVisibility.UserWorkPlanes = False	' Hide all user-created workplanes

 (This creates a new part file each time. The reason for that is so that the face numbering starts at one even if you run the code several times.)

 

Press Home view so the the model is visible. Enter Nastran-In-CAD and start the Idealization command. Select "Shell Elements" and check the "Associated Geometry" box. When selecting a face I can see the ID it has.

Nastran_select_face.JPG

If I run the code several times and check the numbering of the faces I get different results. Here is a picture with some of the combinations (model in the same view as above):

Numbering.jpg

Anyone that has an idea how to fix this or if there is a way to work around this problem? Any thoughts are appreciated!

0 Likes
467 Views
2 Replies
Replies (2)
Message 2 of 3

YuhanZhang
Autodesk
Autodesk

Actually you should not rely on that the created Face objects have fixed numbering(sequence) even with the same creation procedure, the best way to identify a Face is to use its geometry info(like position, shape, normal, area etc.).



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 3

Anonymous
Not applicable

Okey, thanks for the tip!

0 Likes