Message 1 of 11
How to split a surface from rectangular pattern feature occurrence
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everybody,
I have a surface with random boundary. I want to split it to many smaller surface. But i can not find out the way quickly.
Currently, I import a autocad file, create a boundary patch surface, create a rectangular sketch and extrude surface.
Split extrude surface. Pattern extrude surface to continue split.
But now, i can not split from pattern elements. How should i do ?
Thank you.
Here is my code.
Private Sub CommandButton3_Click() Dim dientich As Double ' Dim oDoc As PartDocument ' Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject) Dim oDoc As PartDocument Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject, _ ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject, kMetricSystemOfMeasure)) Dim oCompDef As PartComponentDefinition Set oCompDef = oDoc.ComponentDefinition Dim oRefComponents As ReferenceComponents Set oRefComponents = oCompDef.ReferenceComponents ' Create a ImportedComponentDefinition based on an AutoCAD file. Dim oImportedCompDef As ImportedComponentDefinition Set oImportedCompDef = oRefComponents.ImportedComponents.CreateDefinition("C:\Users\Sand Man\Desktop\Drawing1.dwg") Dim oImportedDWGDef As ImportedDWGComponentDefinition If oImportedCompDef.Type = kImportedDWGComponentDefinitionObject Then Set oImportedDWGDef = oImportedCompDef Else End End If Dim oMatrix As Matrix Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix oMatrix.SetTranslation ThisApplication.TransientGeometry.CreateVector(0, 0, 10) oImportedDWGDef.Transformation = oMatrix ' Create the ImportedComponent Dim oImportedComponent As ImportedComponent Set oImportedComponent = oRefComponents.ImportedComponents.Add(oImportedDWGDef) Dim oImportedDWGComponent As ImportedDWGComponent If oImportedComponent.Type = kImportedDWGComponentObject Then Set oImportedDWGComponent = oImportedComponent Dim oSk As PlanarSketch Set oSk = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3)) ' Get the DWGBlockDefinition for model space. Dim oDWGModelSpaceDef As DWGBlockDefinition Set oDWGModelSpaceDef = oImportedDWGComponent.ModelSpaceDefinition ' Project DWG entities to planar sketch. Dim oDWGEntity As DWGEntity For Each oDWGEntity In oDWGModelSpaceDef.Entities Call oSk.AddByProjectingEntity(oDWGEntity) Next End If oImportedDWGComponent.Visible = False Dim oProfile As Profile Set oProfile = oSk.Profiles.AddForSurface Dim opatchdef As BoundaryPatchDefinition Set opatchdef = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition opatchdef.BoundaryPatchLoops.Add oProfile Dim opatchsurface As BoundaryPatchFeature Set opatchsurface = oCompDef.Features.BoundaryPatchFeatures.Add(opatchdef) Dim oFrontFace As Face Set oFrontFace = opatchsurface.Faces.Item(1) 'Dim odientichtoanbo As Double 'odientichtoanbo = oFrontFace.Evaluator.Area 'Set oFrontFace = oextrude.StartFaces.Item(1) '''''''''''''''''' Dim oWorkplanes As WorkPlanes Set oWorkplanes = oDoc.ComponentDefinition.WorkPlanes Dim oWorkplane As WORKPLANE 'Set oWorkplane = oPartDoc. Dim oSketch As PlanarSketch Set oSketch = oCompDef.Sketches.Add(oFrontFace, False) Dim oTransi As TransientGeometry Set oTransi = ThisApplication.TransientGeometry Dim oRectangleLines As SketchEntitiesEnumerator Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _ oTransi.CreatePoint2d(0, 0), _ oTransi.CreatePoint2d(5, 15)) Set oProfile = oSketch.Profiles.AddForSurface Dim oextrude As ExtrudeFeature Set oextrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, 5, kSymmetricExtentDirection, kSurfaceOperation) 'Dim o2dpath As SplitFeature 'Set o2dpath = oCompDef.Features.CreatePath(oRectangleLines) Dim osur As SurfaceBody Set osur = opatchsurface.SurfaceBodies.Item(1) Dim oworksface As WorkSurface Set oworksface = oextrude.SurfaceBody.Parent Dim oSplit As SplitFeature Set oSplit = oCompDef.Features.SplitFeatures.SplitFaces(oworksface, True, osur) oworksface.Visible = False 'pattern Dim opartdef As PartComponentDefinition Set opartdef = oDoc.ComponentDefinition Dim ocolextrude As ObjectCollection Set ocolextrude = ThisApplication.TransientObjects.CreateObjectCollection Call ocolextrude.Add(oextrude) Dim orecpa As RectangularPatternFeature Set orecpa = oCompDef.Features.RectangularPatternFeatures.Add(ocolextrude, opartdef.WorkAxes.Item(1), False, 6, 5, kDefault, , opartdef.WorkAxes.Item(2), True, 5, 15, kDefault, , kIdenticalCompute) 'For i = 9 To 12 'orecpa.PatternElements.Item(i).Suppressed = True 'Next 'Dim obodyi As WorkSurface 'Set obodyi = orecpa.PatternElements.Item(3).Parent 'Set obodyi = orecpa.SurfaceBodies.Item(1) Set oSplit = oCompDef.Features.SplitFeatures.SplitFaces(odofyi, True, osur) ThisApplication.CommandManager.ControlDefinitions.Item("AppViewCubeHomeCmd").Execute oDoc.Update End Sub