Imports System.Runtime.InteropServices
Public Class Dimple
Private Sub btnDimple_Click(sender As System.Object, e As System.EventArgs)
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objPartDoc As SolidEdgePart.PartDocument = Nothing
Dim objDimple As SolidEdgePart.Dimple = Nothing
Dim objDimples As SolidEdgePart.Dimples = Nothing
Dim objModels As SolidEdgePart.Models = Nothing
Dim objModel As SolidEdgePart.Model = Nothing
Dim objProfile As Object
Dim objProfArr(0 To 1) As Object
Dim objLines As Object
Dim lngStatus As Long
Dim objRelns As Object
Dim nCnt As Object
Dim objType As Type = Nothing
Try
' Create/get the application with specific settings
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
If objApplication Is Nothing Then
' Get the type from the Solid Edge ProgID
objType = Type.GetTypeFromProgID("SolidEdge.Application")
' Start Solid Edge
objApplication = Activator.CreateInstance(objType)
' Make Solid Edge visible
objApplication.Visible = True
End If
' Get open document having simple extruded model with sketches drawn on it
objPartDoc = objApplication.ActiveDocument
' get the models collection
objModels = objPartDoc.Models()
objModel = objModels.Item(1)
objDimples = objModel.Dimples
If objDimples Is Nothing Then
MessageBox.Show("Failed to get the Dimples collection")
End If
objProfile = objPartDoc.ProfileSets.Add.Profiles.Add(objPartDoc.RefPlanes.Item(3))
objLines = objProfile.Lines2d
Call objLines.AddBy2Points(X1:=-0.08, Y1:=-0.05, X2:=0.06, Y2:=-0.05)
Call objLines.AddBy2Points(X1:=0.06, Y1:=-0.05, X2:=0.06, Y2:=0.04)
Call objLines.AddBy2Points(X1:=0.06, Y1:=0.04, X2:=-0.08, Y2:=0.04)
Call objLines.AddBy2Points(X1:=-0.08, Y1:=0.04, X2:=-0.08, Y2:=-0.05)
Call objLines.AddBy2Points(X1:=-0.5, Y1:=-0.07, X2:=-0.3, Y2:=-0.07)
Call objLines.AddBy2Points(X1:=-0.5, Y1:=-0.07, X2:=-0.5, Y2:=0.07)
Call objLines.AddBy2Points(X1:=-0.5, Y1:=0.07, X2:=-0.3, Y2:=0.07)
Call objLines.AddBy2Points(X1:=-0.3, Y1:=0.07, X2:=-0.3, Y2:=-0.07)
objRelns = objProfile.Relations2d
Call objRelns.AddKeypoint(Object1:=objLines.Item(1), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(2), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines.Item(2), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(3), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines.Item(3), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(4), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines.Item(4), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(1), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines.Item(5), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(6), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines.Item(6), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(7), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines.Item(7), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(8), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines.Item(8), Index1:=SolidEdgeConstants.KeypointIndexConstants.igLineEnd, Object2:=objLines.Item(5), Index2:=SolidEdgeConstants.KeypointIndexConstants.igLineStart)
lngStatus = objProfile.End(ValidationCriteria:=SolidEdgeConstants.ProfileValidationType.igProfileNoSelfIntersect)
If lngStatus <> 0 Then
MessageBox.Show("Profile not closed")
End If
nCnt = objPartDoc.ProfileSets.Count()
'get profiles from profile set
objProfArr(0) = objPartDoc.ProfileSets.Item(2).Profiles.Item(1)
' Create Dimple object
objDimple = objDimples.AddEx(
1,
objProfArr,
0.15,
SolidEdgePart.DimpleFeatureConstants.seDimpleProfileLeft,
SolidEdgePart.DimpleFeatureConstants.seDimpleDepthRight,
0.001,
0.002,
0.0,
SolidEdgePart.DimpleFeatureConstants.seDimpleMaterialOutside,
0.001,
SolidEdgePart.DimpleFeatureConstants.seDimpleDimensionFull,
SolidEdgePart.DimpleFeatureConstants.seDimpleRoundEdges,
SolidEdgePart.DimpleFeatureConstants.seDimpleRoundCorners)
If objDimple Is Nothing Then
MessageBox.Show("Failed to Add Dimple object")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class