CreateRailRevolvedSurface Replay Turns PolySrf Into Srf

SDKRailRevolveBug.3dm (135.0 KB)

Somehow NurbsSurface.CreateRailRevolvedSurface() is turning a polycurve with 5 segments into a single surface, but only on the replay.


Top: when first created; Bottom: after history replay

I don’t know how this is possible (polysrf → srf). Plus, the same line of code creates the Brep for both creation and history replay:

NurbsSurface.CreateRailRevolvedSurface(profileCurve, railCurve, axisLine, false).ToBrep()

Here are the relevant What’s:

PolyCurve
curve
  
  ID: 02f09fd2-65a7-438d-9365-03afcbc1c245 (3397)
  Object name: (not named)
  Layer name: Profile
  Render Material: 
    source = from layer
    index = -1
  Attribute UserData:
    UserData ID: 563238F9-C201-411d-A7B1-13895A0317AD
    Plug-in: Rhino
      description: AutoPointsOn
      saved in file: no
      copy count: 1
    UserData ID: CE28DE29-F4C5-4faa-A50A-C3A6849B6329
    Plug-in: 17b3ecda-17ba-4e45-9e67-a2b8d9be520d
      description: User text (0 entries)
      saved in file: yes
      copy count: 15
    UserData ID: 0D007E84-79CC-4b4a-850B-C23EF2CEC640
    Plug-in: Rhino
      description: Hide user data
      saved in file: yes
      copy count: 13
  
  Geometry:
    Valid curve.
    Closed polycurve with 5 curve segments.
      Segment 1:
        Open NURBS curve
          start = (-7.58378,0,14.9537)
          end = (-7.3311,-2.77556e-17,15.7731)
          degree = 3
          control points: non-rational, count=6
          knots: uniform (delta=0.310047), domain = 2.45935 to 3.38949
          clamped at start and end
      Segment 2:
        Open NURBS curve
          start = (-7.3311,-2.77556e-17,15.7731)
          end = (-7.10786,-1.38778e-17,15.5498)
          degree = 1
          control points: non-rational, count=2
          knots: uniform (delta=0.315713), domain = 3.38949 to 3.7052
          clamped at start and end
      Segment 3:
        Open NURBS curve
          start = (-7.10786,-1.38778e-17,15.5498)
          end = (-5.91628,0,13.9982)
          degree = 3
          control points: non-rational, count=5
          knots: uniform (delta=1.37161), domain = 3.7052 to 6.44843
          clamped at start and end
      Segment 4:
        Open NURBS curve
          start = (-5.91628,0,13.9982)
          end = (-10.06,0,14.3759)
          degree = 5
          control points: non-rational, count=11
          knots: uniform (delta=1), domain = 6.44843 to 12.4484
          clamped at start and end
      Segment 5:
        Line
          start = (-10.06,0,14.3759)
          end = (-7.58378,0,14.9537)
          domain = 12.4484 to 14.9078
          line length = 2.54271
  History:
    Record index: 1
    Record id: DE60084C-7B39-4180-9676-D7B0C7A6C365
    Command: Transform


Original PolySrf
polysurface
  
  ID: 24106d34-4264-40ee-bf25-c2000cd7c5b9 (3394)
  Object name: (not named)
  Layer name: Srf
  Render Material: 
    source = from layer
    index = -1
  
  Geometry:
    Valid polysurface.
    closed solid polysurface with 5 surfaces.
  Edge Tally:
      5 seam edges
      5 manifold edges
    = 10 total edges
  Edge Tolerances: all 0
  Vertex Tolerances: all 0
  Render mesh: 5 meshes  4175 vertices  4476 polygons
    Created with fast meshing parameters.
  Analysis mesh: none present
History:
  Record index: 2
  Record id: 9FDB3D60-F810-4883-AAD3-6AF7768D297A
  Command: Revolv


Replay Srf
surface
  
  ID: c9a5fa9b-b3b8-4358-821a-11aed2e3d0b9 (3393)
  Object name: (not named)
  Layer name: Srf
  Render Material: 
    source = from layer
    index = -1
  Attribute UserData:
    UserData ID: CE28DE29-F4C5-4faa-A50A-C3A6849B6329
    Plug-in: 17b3ecda-17ba-4e45-9e67-a2b8d9be520d
      description: User text (0 entries)
      saved in file: yes
      copy count: 12
  
  Geometry:
    Valid surface.
    closed surface.
      NURBS Surface"U": Periodic  degree =3  CV count = 15  (0 <= U <= 12)
        "V": Closed  degree =5  CV count = 40  (2.45935 <= V <= 14.9078)
  Edge Tally:
      2 seam edges
  Edge Tolerances: all 0
  Vertex Tolerances: all 0
  Render mesh: 1 mesh  3137 vertices  2352 polygons
    Created with fast meshing parameters.
  Analysis mesh: none present
History:
  Record index: 0
  Record id: 4B7BFA7E-A64E-4c1e-B131-57E20F324F83
  Command: Revolv

@Gijs has RailRevolveSG that is very similar to this. Posting his cause it’s c# and shows the exact same behavior:

@EricM - in your replay code, do something like this:

NurbsSurface rev = NurbsSurface.CreateRailRevolvedSurface(curve, railcurve, revline, false);
if (null != rev)
{
  Brep brep = rev.ToBrep();
  if (null != brep)
  {
    // Split 'em
    brep.Faces.SplitKinkyFaces();
    replay.Results[0].UpdateToBrep(brep, null);
  }
}

– Dale

Just for the replay?

I’m really confused why this method returns a different surface depending on if it’s being executed from a replay. How is it aware of the caller’s context, and why would it act differently?

@EricM - kinky Breps are automatically split when adding them to the document. I don’t believe command replay does this for you.

– Dale

1 Like

Got it. I fixed a few of my other commands that would have had the same issue.

// Nulls.bind: if not null then do x 
match output.RailCrvOpt with
| Somev rail ->
	NurbsSurface.CreateRailRevolvedSurface(output.ProfileCrv.Obj, rail.Obj, axis, false)
	|> Nulls.bind (_.ToBrep())
| Nonev ->
	RevSurface.Create(output.ProfileCrv.Obj, axis)
	|> Nulls.bind (_.ToBrep())
|> Nulls.trySome (fun x ->
		match x.Faces.SplitKinkyFaces() with
		| true -> Some x
		| false -> None    )