Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5849

Deleting UserText Keys and data from a script

$
0
0

@philshapiro wrote:

Hi,
I’m a bit stuck I’m trying to clear objects of any keys and data associated through a script.
I’ve tried to use the DeleteObjectData method frome Rhino Script but the keys are not deleted. ( This method is not available in Python (Rhino 5.0)

Option Explicit
Call Main()
Sub Main()
	Dim arrlistObj,strObject

	arrlistObj = Rhino.GetObjects("SelectObjects")
	For Each strObject In arrlistObj
		If Not IsNull(strObject) Then
			Call Rhino.DeleteObjectData(strObject)
		End If
	Next
End Sub

I’ve also tried using the command option suggested by Helvetosaur and Pacal, setting the key to “” in a Python script. This does not work either.

import rhinoscriptsyntax as rs

listObj = rs.GetObjects("Select objects")
for obj in listObj:
    listKeys = rs.GetUserText(obj)
    if listKeys:
        for key in listKeys:
            rs.SelectObject(obj)
            empty = '""'
            strDel = "_SetUserText "+key+" "+empty
            rs.Command(strDel)
        rs.Command("_SelNone")

If you have any suggestions or if you can see what I’m doing wrong here.
Cheers
Phil

Posts: 5

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 5849

Latest Images

Trending Articles



Latest Images