Merge 4 Surfaces

Hi Everybody!

I have created a script that merges 4 surfaces. I start merging surfaces 2 by 2 using the Rhino.Command “MergeSrf”. This works fine until I try to merge the last 2 surfaces using the exact same command. I have the following error message: Can’t determine which edges to merge. Pick near edges to merge.

I don’t understand why I have an error message as it works fine when I merge the 2 last surfaces manually in Rhino.

Attached are my 4 surfaces and the rvb file:
Untitled.3dm (66.7 KB)
Merge.rvb (549 Bytes)

Thank you for your help!

Julien

You work on a name basis. After the MergeSrf command, the resulting merged surface gets the name of the first surface selected. It will probably work like this (remove the comments after the //)

Option Explicit
    
Dim obj1,obj2
    
obj1 = Rhino.ObjectsByName("PortBot", True) // first name is PortBot
obj2 = Rhino.ObjectsByName("PortTop", True)
    Call Rhino.Command("MergeSrf obj1 obj2 _Enter")
Rhino.Command "_-SelNone", 0
    
obj1 = Rhino.ObjectsByName("StbBot", True) // first name is StbBot
obj2 = Rhino.ObjectsByName("StbTop", True)
    Call Rhino.Command("MergeSrf obj1 obj2 _Enter")
Rhino.Command "_-SelNone", 0
    
obj1 = Rhino.ObjectsByName("PortBot", True) //use the first name from above
obj2 = Rhino.ObjectsByName("StbBot", True) // use the first name from above
    Call Rhino.Command("MergeSrf obj1 obj2 _Enter")
Rhino.Command "_-SelNone", 0

Yes I understood this. This is the reason why the last MergeSrf was being done with “PortBot” and “StbBot”.
The last MergeSrf does not work and has the following error: Can’t determine which edges to merge. Pick near edges to merge.
I would like to understand and fix this error.

Thank you for your help.

I think I’d ask for the LastCreatedObject rather than rely on object name-

If Rhino.LastCommandResult() = 0 then
obj1 = Rhino.LastCreatedObjects()(0)

something like that.

-Pascal

The script selects the surfaces correctly.
What I need to do is specify the “nead edges” while calling the MergeSrf function. How can I do this?

Thank you!

Julien

This is as close as I can get:

Sub Main()

	Dim obj1, obj2, merge1, merge2
	
	Call Rhino.UnselectAllObjects

	obj1 = Rhino.ObjectsByName("StbBot", True)
	obj2 = Rhino.ObjectsByName("StbTop", True)
	Call Rhino.Command("_MergeSrf _SelID obj1 _SelId obj2 _Enter")
	merge1 = Rhino.LastCreatedObjects
	Call Rhino.UnselectAllObjects
	If Not IsArray(merge1) Then Exit Sub
	
	obj1 = Rhino.ObjectsByName("PortBot", True)
	obj2 = Rhino.ObjectsByName("PortTop", True)
	Call Rhino.Command("_MergeSrf _SelID obj1 _SelId obj2 _Enter")
	merge2 = Rhino.LastCreatedObjects
	Call Rhino.UnselectAllObjects
	If Not IsArray(merge2) Then Exit Sub

	obj1 = Rhino.SelectObject(merge1(0))
	obj2 = Rhino.SelectObject(merge2(0))
	Call Rhino.Command("_MergeSrf _SelID obj1 _SelId obj2 _Smooth=_Yes _Tolerance=0.1 _Roundness=1 _Enter")
	'Call Rhino.UnselectAllObjects
	
End Sub

The issue is the command needs help in knowing which edges to use. This is something you cannot specify via scripting.

I’ve added a new MergeSurfaces metthod to RhinoScript for V6. This method allows you to specify “pick points.” This should help. Again, for V6 only…

Thanks Dale for the answer.
So I look forward to using the V6 release :wink:

One question:
When I call Mergesrf in Rhino (i.e. manually) it does not ask me any edge to use and the merge succeeds.
Could you explain me why the script then needs to know which edges to use?

Tks

Are you pre-selecting the objects to merge? Or are you post-selecting, in which case the command know here on the objects you picked…

I was post-selecting while proceeding manually.
If I pre-select, I have the same warning signal than my script…