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?
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.
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.
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:
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.
@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.