Python guid error

python

#1

Hi, I need some help,

I have a Python for loop and got the "Message: Parameter must be a Guid or string representing a Guid"
I am looping a list but not sure what is the right format of the Guid.

in-between single quotes
’<System.Guid object at 0x0000000000000039 [09c04700-f879-4e06-8432-f1a381f781f7]>'
without single quotes
<System.Guid object at 0x0000000000000039 [09c04700-f879-4e06-8432-f1a381f781f7]>
or simple ID
[09c04700-f879-4e06-8432-f1a381f781f7]


#2

show the code
:wink:


#3

Hello Jeff,

The question is what format do I have to use to listToExtend that is accepted as Guids.

listToExtend = [ list content]
listBaseExtend = [ list content lots of curves by selection get.Objects]

for i in listToExtend:
    print "i:" 
    print i 
    rs.ExtendCurve (i, 0, 0, listBaseExtend)

(Giulio Piacentino) #4

When using RhinoScriptSyntax, a Guid can be a string containing the ID itself
e.g., "09c04700-f879-4e06-8432-f1a381f781f7"

or a System.Guid type constructed normally,
e.g., System.Guid("09c04700-f879-4e06-8432-f1a381f781f7")

Both ways should work, and the first one is actually transformed to the second one, by the coerceguid() function.

There are some other minor options. Have a look at the function for the full implementation.

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#5

It is weird;

for t in thicknessPlus:
    layer = rs.OffsetCurve(polyline, offsetDirection, t) 
    if layer:
        for c in layer:
            objectList.append(c)

objectListTxt = rs.SetUserText (polyline, "Layer order", objectList , False)

When I loop it the result is:

[<System.Guid object at 0x00000000000000B5 [0d4e55dd-6d90-4841-9c4a-12fd661bb2be]>, <System.Guid object at 0x00000000000000B6 [e98495b5-d9b3-4d74-befd-77bdbd9e213f]>, … ]


#6

Eventually,

I used;

objectList.append(str(c))

and it works.


#7

It seems when I extract the string from a User Text does not work but when I put it into a single string it works fine.


(Giulio Piacentino) #8

I am still not sure exactly what you were trying to do, but if it works, it must be right :smiley:

Thanks

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#9

Ok, it works. When new items have been added to the list python add an extra space " " and when I extracted the string, Python did not recognized the full text, so I had to remove the space.


(Giulio Piacentino) #10

Thanks, @onrender

If you think it’s a bug, please send me the .gh or the .py file so I can take a look!
Thanks!

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com