Copy EllipticalCylinder Face EdgeLoopDefinition

Copy EllipticalCylinder Face EdgeLoopDefinition

J-Camper
Advisor Advisor
276 Views
0 Replies
Message 1 of 1

Copy EllipticalCylinder Face EdgeLoopDefinition

J-Camper
Advisor
Advisor

I have a script that finds orientedrangebox for each face shell of a multi-solid Part.  The EllipticalCylinderSurface Face.SurfaceType is the only type I use regularly that is giving me issues with the script so far. 

 

Here is my testing Script [I commented out the EdgeLoopDefinition Build attempt so this should output "Ignore face/Ignore EdgeLoop"]:

Sub Main
	
	Dim pDef As PartComponentDefinition = TryCast(ThisApplication.ActiveDocument.ComponentDefinition, PartComponentDefinition)
	If IsNothing(pDef) Then Exit Sub
	
	For Each oSolid As SurfaceBody In pDef.SurfaceBodies
		If oSolid.FaceShells.Count > 1
		Logger.Trace("Multi body: " & oSolid.FaceShells.Count)
				
		For Each fs As FaceShell In oSolid.FaceShells
			
			'Define Objects to create transient copy
			Dim sbDef As SurfaceBodyDefinition = ThisApplication.TransientBRep.CreateSurfaceBodyDefinition 
			Dim lumpDef As LumpDefinition = sbDef.LumpDefinitions.Add()
			Dim fsDef As FaceShellDefinition = lumpDef.FaceShellDefinitions.Add()
			
			'Start to fill Definition
			For Each f As Face In fs.Faces
				If f.SurfaceType <> SurfaceTypeEnum.kEllipticalCylinderSurface 'Having issues with this type of surface
					Dim fDef As FaceDefinition = fsDef.FaceDefinitions.Add(f.Geometry, f.IsParamReversed)
					Dim elDef As EdgeLoopDefinition = fDef.EdgeLoopDefinitions.Add()
					For Each ed As Edge In f.EdgeLoops.Item(1).Edges
						elDef.EdgeUseDefinitions.Add(sbDef.EdgeDefinitions.Add(sbDef.VertexDefinitions.Add(ed.StartVertex.Point), sbDef.VertexDefinitions.Add(ed.StopVertex.Point), ed.Geometry), ed.IsParamReversed)
					Next
				Else If f.SurfaceType = SurfaceTypeEnum.kEllipticalCylinderSurface 'Is EllipticalCylinderSurface
					Logger.Debug(oSolid.Name & " ingored an EllipticalCylinderSurface") ': Continue For
					Dim ec As EllipticalCylinder = f.Geometry
					Dim ecFaceDef As FaceDefinition = fsDef.FaceDefinitions.Add(ec, f.IsParamReversed)
					Dim ecEdgeLoopDef As EdgeLoopDefinition = ecFaceDef.EdgeLoopDefinitions.Add()
					For Each ed As Edge In f.EdgeLoops.Item(1).Edges
						
						
						'How do i need to change this to get the face to copy properly?
						
						
						'Logger.Trace(CType(ed.GeometryType, CurveTypeEnum).ToString)
						If ed.GeometryType <> CurveTypeEnum.kEllipticalArcCurve
							'ecEdgeLoopDef.EdgeUseDefinitions.Add(sbDef.EdgeDefinitions.Add(sbDef.VertexDefinitions.Add(ed.StartVertex.Point), sbDef.VertexDefinitions.Add(ed.StopVertex.Point), ed.Geometry), ed.IsParamReversed)
						Else
							Logger.Debug(oSolid.Name & " ingored an EllipticalArcEdge") ': Continue For
						End If
					Next
				End If
			Next
			'Logger.Trace("Attempt Body creation")
			Dim oErrors As NameValueMap
			Dim TransBody As SurfaceBody = sbDef.CreateTransientSurfaceBody(oErrors)

			pDef.Features.NonParametricBaseFeatures.Add(TransBody)
			
			Exit For 
		Next
		
		Else If oSolid.FaceShells.Count = 1
			Logger.Trace("Single")
		End If
	Next
End Sub

 

I will also post an image of milestones during my investigation:

temp_pic.JPG

 

My actual script is currently ignoring the EllipticalCylinder Faces because ≈90+% of the instances of this Face.SurfaceType are not setting the bounds of the orientedRangebox that this part of the actual script ever sees.  I am still interested in how I can modify the code to copy this SurfaceType properly, to make it fully functional

 

Any help or insight is appreciated.

0 Likes
277 Views
0 Replies
Replies (0)