Problem with CreateSoftEditSurface parameters

I am having trouble making the CreateSoftEditSurface method change a surface. I think the parameters are correct, but the surface is not moving. There isn’t any error messages.

Here is the test script that I am working on:

import rhinoscriptsyntax as rs
import Rhino

surfaceGUID = rs.GetObject('Pick the surface to soft edit...', rs.filter.surface)
pointOnSurface = rs.GetPointOnSurface(surfaceGUID, 'Pick point on the surface to edit...')
 
# List of U and V parameters at the point
UV = rs.SurfaceClosestPoint(surfaceGUID, pointOnSurface)
P2d = rs.coerce2dpoint(UV)
 
# Surface normal at the point (should be a unit vector)
N  = rs.SurfaceNormal(surfaceGUID, UV)
 
# Move 6 units in the surface normal direction
Move = rs.VectorScale(N, 6)
 
# Get the current "model absolute tolerance"
Tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance
 
Surf = rs.coercesurface(surfaceGUID)
 
SO = Rhino.Geometry.Surface.CreateSoftEditSurface(Surf, P2d, Move, 2, 2, Tol, False)

Could somebody please let me know what I am doing wrong?

Thanks for your time.

1 Like

Hi Henry - rs.corercesurface(id) actually returns a brep face and not a surface object - you probably want Surf.UnderlyingSurface() as your input for the Softedit guy.

-Pascal

1 Like

Hi @Henry_Wede, i see a change if i add the resulting Nurbs surface to the document or replace the original input surface with the result like this:

scriptcontext.doc.Objects.Replace(surfaceGUID, SO)
scriptcontext.doc.Views.Redraw()

you’ll also need to import the scriptcontext module on top of your script.

_
c.

After incorporating the suggestions from @pascal and @clement above, I have something that ~works~ but the movement is not as expected.

I added a couple lines of code to draw a line (and dots) from the CreateSoftEditSurface start point and end point. I do NOT expect the magnitude to be correct. In the final form this will have to be an automated iterative process. However, the point on the surface getting the most movement seems to be the closest control point and not the point passed into the CreateSoftEditSurface method. This behavior is not the same as the SoftEditSrf command.

Oh… having to use the scriptcontext.doc.Objects.Replace method to actually see the movement also deletes the trims on the surface which makes that unusable. It reverts back to the untrimmed state.

Here is an image of the unsuspecting surface

Here is what it looks like after this script chooses the point shown
ManualSoftEditTest.py (1.2 KB)

The untrimmed part of the surface comes back, and the “peak” of the surface is not where the user selected. This solution is not going very well :slight_smile:

Are we sure that there is no way to “script” the SoftEditSrf command and turn this stuff into something that Python can put points into?

Command: _SoftEditSrf
Select surface ( U_Distance=1 V_Distance=1 Copy=No FixEdges=No DirConstraint=SrfNormal )
Base point. Press Enter when done ( U_Distance=1 V_Distance=1 Copy=No FixEdges=No DirConstraint=SrfNormal )
To point ( U_Distance=1 V_Distance=1 Copy=No FixEdges=No DirConstraint=SrfNormal )

It is not a beautiful Python solution, but I will get over it.

1 Like

Hi @Henry_Wede, i do not see this. The behaviour of using the closest control point to move is identical using _SoftEditSrf command in Rhino. Note where i pick the srf and which control point is highlighted and moved:

SoftEditSrf

Yes, in order to keep the trims in the result obtained by scripting, you’ll need to copy them from the source brep face to the resulting nurbs surface. See example below. Note that this script does not replace your input. Instead it adds it to the document for easier comparison.

I’ve compared a test result of this script with the result of using _SoftEditSrf command and both where detected using _SelDup, so i asume they are identical including the trims.

HW_CreateSoftEditSurface.py (1.4 KB)

_
c.

@clement Yes, you are correct. It is doing what the SoftEditSrf command is doing. Hopefully, somebody searching this topic on the forum can use the previously attached script as a starting point.

Unfortunately, the start of this adventure (way back here HBar scripting post) was to select a point on the surface and move it like the handlebar editor does. That behavior is exactly what the project requires. All of the soft edit functions snap to the nearest control point and move it. In your movie, you click one place and a black line arrow starts moving at the nearest control point. And that is OK - that is what the developers were hoping to achieve.

It is frustrating to see the handle bar editor do exactly what would make this project a success, and not be able to do it with scripting. The alternative, which we did on a previous project, it orders of magnitude more difficult and prone to errors. It is going to be a tough project moving forward but it looks like that is the only choice.

As always, thanks for your time in replying and offering so much knowledge.

1 Like