Cancel
Showing results for 
Search instead for 
Did you mean: 

API to Break Curves By Selecting Multiple Points

Siemens Phenom Siemens Phenom
Siemens Phenom

The attached API (code shown below) breaks curves by projecting the selected points onto selected curves.

 

You first select the points that you want to break curves with, then it cycles through the set of selected points, highlights them, then you select the curve(s) that you want to break with that point.

 

A video is also attached.

 

The HTML Clipboard

Rem
Rem     Break Curves By Selecting Points
Rem
Rem     C.R. "Chip" Fricke
Rem     chip.fricke@siemens.com
Rem

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim rc As femap.zReturnCode

    Dim ptSet As femap.Set
    Set ptSet = App.feSet
    Dim ptID As Long
    Dim ptC As Variant

    SelectPoints:
    rc = ptSet.Select ( FT_POINT, True, "Select Split Points" )
    If rc <> FE_OK Then
        End
    End If
    Dim tempSet As femap.Set
    Set tempSet = App.feSet

    Dim cuSet As femap.Set
    Set cuSet = App.feSet
    Dim cuID As Long

    ptSet.Reset
    ptID = ptSet.First
    For i = 0 To ptSet.Count-1
        tempSet.Clear
        tempSet.Add ( ptID )
        tempSet.Show ( FT_POINT )
        App.feCoordOnPoint ( ptID, ptC )
        rc = cuSet.Select ( FT_CURVE, True, "Select Curve(s) to Break" )
        If rc = FE_CANCEL Then
            GoTo SelectPoints
        End If
        cuSet.Reset
        cuID = cuSet.First
        While cuID <> 0
            rc = App.feCurveBreak ( cuID, ptC )
            If rc = FE_OK Then
                App.feViewRegenerate ( 0 )
            End If
            cuID = cuSet.Next
        Wend

        ptID = ptSet.Next
    Next i

    App.feViewRegenerate ( 0 )

End Sub

Best Regards,
Chip Fricke
Principal Applications Engineer - Femap Product Development
2 REPLIES

Re: API to Break Curves By Selecting Multiple Points

Legend
Legend

Hello Chip,

 

here is my API that I use for many years to break curves at multiple points in one step. I think it was fine if Femap had similar built-in command. You can select curves and coordinates of the break points (or uncommenting selection part of macro to select existing points and deleting part of selection points by its coordinates, to selecting existing points):

 

Sub Main  'BreakCurvesAtMultiplePoints by Peter Kaderasz

  Dim App As femap.model
  Set App = feFemap()

  Dim curveSet As femap.Set
  Set curveSet = App.feSet
  Dim cu As femap.Curve
  Set cu = App.feCurve

  Dim pointSet As femap.Set
  Set pointSet = App.feSet
  Dim pt As femap.Point
  Set pt = App.fePoint
  Dim ptCoord As Variant
  Dim pt_tmpCoord As Variant

  Dim Msg As String
  Dim found As Boolean
  Dim break As Integer

  Dim pointID As Long
  Dim pt_tmpID As Long
  Dim pt_newID As Long
  Dim cuID As Long
  Dim cu_newID As Long

  Dim center As Variant
  Dim normal As Variant
  Dim startloc As Variant
  Dim endloc As Variant
  Dim angle As Double
  Dim radius As Double
  Dim s As Double
  Dim dist As Double
  Dim tolerance As Double

  tolerance=0.0001
  break=0

  App.feAppMessage( FCM_COMMAND  , "Break Multiple Curves at Multiple Points")  '0 = Normal; 1 = Highlight; 3 = piros (Error)

  rc = curveSet.Select( FT_CURVE, True, "Select Curve(s) to Break")

  If rc = FE_CANCEL Or curveSet.Count=0 Then
    App.feAppMessage( FCM_ERROR, "Curve not found - Cancelled")
    App.feViewRegenerate( 0 )
    Exit Sub
  End If

  'Selecting existing points
  'rc = pointSet.Select( FT_POINT, True, "Select Break Points (Cancel to Abort)")
  'If rc = FE_CANCEL Or pointSet.Count=0 Then
  '  App.feAppMessage( FCM_ERROR, "Point(s) not found - Cancelled")
  '  App.feViewRegenerate( 0 )
  '  Exit Sub
  'End If

  'Selecting point by its coordinates
  rc=FE_OK
  While rc<>FE_CANCEL
    rc=App.feCoordPick("Locate - Enter Location to Break at Curves (Cancel to Abort)",ptCoord)
    If rc<>FE_CANCEL Then
      found=False
      pt_tmpID=pointSet.First
      While pt_tmpID>0
        rc=pt.Get(pt_tmpID)
        pt_tmpCoord=pt.xyz
        If ptCoord(0) = pt_tmpCoord(0) And ptCoord(1) = pt_tmpCoord(1) And ptCoord(2) = pt_tmpCoord(2) Then
          found=True
          Exit While
        End If
        pt_tmpID=pointSet.Next
      Wend
      If Not found Then
        pt_newID=App.Info_NextID(FT_POINT)
        pt.xyz=ptCoord
        rc=pt.Put(pt_newID)
        rc=pointSet.Add(pt_newID)
      End If
    End If
  Wend

  If pointSet.Count=0 Then
    App.feAppMessage( FCM_ERROR, "Break Location(s) not found - Cancelled")
    App.feViewRegenerate( 0 )
    Exit Sub
  End If

  pointID=pointSet.First

  While pointID>0

    rc = pt.Get(pointID)
    ptCoord=pt.xyz

    cuID=curveSet.First

    While cuID>0

      rc=cu.Get(cuID)
      rc=cu.ArcCircleInfo(center, normal, startloc, endloc, angle, radius)
      If rc<>FE_FAIL Then  'Not Arc or not Circle
        rc=App.feMeasureDistance(center, ptCoord, dist)
        If dist<tolerance Then GoTo Tovabb
      End If
      rc=cu.XYZToParam(ptCoord,s)
      If s<=0 Or s>=1 Then GoTo Tovabb  'Startpoint, Endpoint, or outer Curve
      cu_newID=App.Info_NextID(FT_CURVE)
      rc=App.feCurveBreak(cuID, ptCoord)
      If rc<>FE_FAIL Then
        rc=curveSet.Add(cu_newID)
        break=break+1
      End If

Tovabb:

      cuID=curveSet.Next
    Wend

    pointID=pointSet.Next
  Wend

  'If point selected by its coordinates
  If pointSet.Count<>0 Then
    rc = App.feDelete( FT_POINT, pointSet.ID )
  End If

  Msg=Trim(Str(break))+" Breakpoint(s) created."
  App.feAppMessage( FCM_NORMAL ,Msg)
  App.feViewRegenerate( 0 )

End Sub

Best regards

 

Peter Kaderasz

Re: API to Break Curves By Selecting Multiple Points

Siemens Phenom Siemens Phenom
Siemens Phenom

Thanks for sharing

Best Regards,
Chip Fricke
Principal Applications Engineer - Femap Product Development