Strange rs.command behaviour

Hi there,

I would like to use the Split command in the rs.Command method and gives a strange result:

rs.Command("_Split _SelID " + str(baseBdySf) + " _Enter _SelID " + str(cut[0]) + " _Enter ")

ID to base object:
fd69f1f6-547c-4c56-8cd7-27fabe1be761
ID to cutting object:
[<System.Guid object at 0x0000000000000039 [964ed2ca-2603-4657-9180-89460ffb9a9e]>]

Command: _Split
Select objects to split ( Point Isocurve ): _SelID
Object ID to select: [<System.Guid
No objects added to selection.
Select objects to split ( Point Isocurve ): object
Unknown command: object
Select objects to split ( Point Isocurve ): at
Unknown command: at
Select objects to split ( Point Isocurve ): 0x000000000000002E
Unknown command: 0x000000000000002E
Select objects to split ( Point Isocurve ): [baeb84aa-bbe8-489e-bb5a-9ba43603f948]>]
Unknown command: [baeb84aa-bbe8-489e-bb5a-9ba43603f948]>]
Select objects to split ( Point Isocurve ): _Enter
Select objects to split ( Point Isocurve ):

You need this:

rs.Command("_Split SelID " + str(baseBdySf) + " _Enter SelID " + str(cut[0]) + " _Enter")

Note this also works - the format statement takes care of converting the GUID to a string:

rs.Command(("_Split SelID {} _Enter SelID {} _Enter").format(baseBdySf,cut[0]))

I have got same result:

Can a for loop affect the rs.Command? Yesterday I have similar issue, but I thought it is, because the rs.Command() was in a class object, I introduced a bit from RhinoCommon methods, I added the geometries to the ObjectTable first and then the rs.Command() worked fine. Something else cause this issue… I can try to add the geometries to the ObjectTable and let’s see but I wish to find a simple solution for this …

Command: _Split
Select objects to split ( Point Isocurve ): SelID
Object ID to select: [<System.Guid
No objects added to selection.
Select objects to split ( Point Isocurve ): object
Unknown command: object
Select objects to split ( Point Isocurve ): at
Unknown command: at
Select objects to split ( Point Isocurve ): 0x000000000000002F
Unknown command: 0x000000000000002F
Select objects to split ( Point Isocurve ): [570d84e0-118c-48ee-84a6-ac6ce8f7704b]>]
Unknown command: [570d84e0-118c-48ee-84a6-ac6ce8f7704b]>]
Select objects to split ( Point Isocurve ): _Enter

Scripting a Rhino command via rs.Command() or rhinoscriptsyntax methods that use object ID’s requires that the objects already exist in the object table…

Sure. Theoretically all objects are exist. One is a plane, the other is a curve that cuts the plane. All of them are visible on screen when rs.Command() starts.

The cutting objects seem to be in a list. (cut[0])

As there is no code or example file, I don’t know where the problem is.

The code I used to test is this:

import rhinoscriptsyntax as rs
baseBdySf=rs.GetObject("Select base surface",8)
cut=rs.GetObjects("Select splitting curves",4)
rs.Command(("_Split SelID {} _Enter SelID {} _Enter").format(baseBdySf,cut[0]))

With this file: (obviously, from the code, only the first curve in the list splits the surface)
SplitEx.3dm (324.9 KB)

I assume you know this, but if you are trying to loop through and split the surface with multiple curves using this method, this will not work, as after the first split, you have two new object ID’s for the split parts, and the original object ID is lost.

Thanks,

I came up with something for multiple cuts. It works now.

import rhinoscriptsyntax as rs

baseBdySf=rs.GetObject(“Select base surface”,8)
cut=rs.GetObjects(“Select splitting curves”,4)

text = [ "_SelID " + str(id) for id in cut]
text = " ".join(text)
print "cut"
print text
print "_Split _SelID " + str(baseBdySf) + " _Enter " + str(text) + " _Enter "
# rs.Command(("_Split SelID {} _Enter SelID {} _Enter").format(baseBdySf,cut[0]))
rs.Command("_Split _SelID " + str(baseBdySf)  + " _Enter " + str(text) + " _Enter ")

Hmm, interesting innovation. I didn’t know that the command line would accept multiple SelID’s like that. Good to know.

Okay, Thank you for the discussion.

All in all, I finally found the issue. An rs.AddPlanar method caused the issue or eventually I caused the issue when I was not aware of the return type that was a List instead of Guid.

[<System.Guid object at 0x000000000000003F [9c33aa61-4eac-4f19-94c8-28e2f7e2a856]>]

…brackets seemed invisible when I see the one item list.