Tuesday, 23 September 2014

Match Properties for Solid Edge - Part 4

...continued from Part 3

If everything goes well, the user has one object selected with its 4 properties captured. The dialog is floating. Make sure you have set the TopMost property of the Form to True.

At this stage the user goes out and selects the destination objects and clicks the Match button. The code for the Match button first stores the destination selection set:

oSSetDestination = oDoc.SelectSet

If oSSetDestination.Count <= 0 Then
  MsgBox("No destination object(s) selected.", MsgBoxStyle.Information, Me.Text)

If nothing was selected, the user is informed as above.

If there are any objects selected i.e. selection set count is greater than 0, each destination objet type is checked:

ElseIf oSSetDestination.Count > 0 Then
  For cnt As Integer = 1 To oSSetDestination.Count
    oDestin = oSSetDestination.Item(cnt)
      If TypeOf oDestin Is SolidEdgeFrameworkSupport.Line2d Or _
         TypeOf oDestin Is SolidEdgeFrameworkSupport.Arc2d Or _
         TypeOf oDestin Is SolidEdgeFrameworkSupport.Circle2d Or _
         TypeOf oDestin Is SolidEdgeFrameworkSupport.Ellipse2d Or _
         TypeOf oDestin Is SolidEdgeFrameworkSupport.EllipticalArc2d Or _
         TypeOf oDestin Is SolidEdgeFrameworkSupport.BSplineCurve2d Or _
         TypeOf oDestin Is SolidEdgeFrameworkSupport.Point2d Or _
         TypeOf oDestin Is SolidEdgeFrameworkSupport.Group Then

Further, the check box state of each property is checked if user has selected to match any of those:

If chkLayer.Checked Then
  oDestin.Layer = sLayer
End If

If chkColor.Checked Then
  oDestin.Style.LinearColor = iColor
End If

If chkWidth.Checked Then
  oDestin.Style.Width = dWidth
End If

If chkLType.Checked Then
  If Trim(sLtype) <> "" Then
    oDestin.Style.DashName = sLtype
  ElseIf Trim(sLtype) = "" Then
    oDestin.Style.DashName = "Continuous"
  End If
End If

and accordingly each property of the destination object is assigned values of those stored from the source.

Finally, the selection set is emptied.

oSSetDestination.RemoveAll()

The following video demonstrates the working of Match Properties:

The Making of Match Properties for Solid Edge - www.SurfAndCode.in
 

11 Download just the program or executable file.

11 Download the VB.Net (VS 2010, .Net 4.0) solution files.

Modify and use the code as you desire, guilt-free, even commercially.

Index of all Solid Edge Tutorials, Tips, Videos...

No comments:

Post a Comment