Get namespace from selected model but not a namespace list.

Get namespace from selected model but not a namespace list.

爱贝贝
Contributor Contributor
1,481 Views
5 Replies
Message 1 of 6

Get namespace from selected model but not a namespace list.

爱贝贝
Contributor
Contributor
I want to get namespace from selected bone with MoBu python. However this codes get a namespace list . from pyfbsdk import * selected_models = FBModelList() FBGetSelectedModels(selected_models) i = selected_models NS = FBStringList() Count = FBSystem().Scene.NamespaceGetChildrenList(NS) x = i for x in NS: localNS = FBSystem().Scene.NamespaceGet(x) print x How can i do this with MoBu python?
0 Likes
Accepted solutions (1)
1,482 Views
5 Replies
Replies (5)
Message 2 of 6

vdebaie
Advocate
Advocate
Accepted solution

@爱贝贝 wrote:
I want to get namespace from selected bone with MoBu python. However this codes get a namespace list . from pyfbsdk import * selected_models = FBModelList() FBGetSelectedModels(selected_models) i = selected_models NS = FBStringList() Count = FBSystem().Scene.NamespaceGetChildrenList(NS) x = i for x in NS: localNS = FBSystem().Scene.NamespaceGet(x) print x How can i do this with MoBu python?

Do you mean somehthing like this? It will only return the first object in a list - so the first model you select (even if you select multiple models by accident).

from pyfbsdk import *

def GetSelModelNameSpace():
    lSelModels = []
    modelList = FBModelList()
    FBGetSelectedModels (modelList, None, True)
    for model in modelList:
        if model.Selected == True:
           lSelModels.extend( [ model.LongName.rsplit(':', 1)[0] ] )
    return lSelModels[0]
        

        
myNameSpace = GetSelModelNameSpace()
print myNameSpace

 

Message 3 of 6

爱贝贝
Contributor
Contributor

Your answer really helped me,thank you very much!!🙏

0 Likes
Message 4 of 6

爱贝贝
Contributor
Contributor

爱贝贝_0-1611110418223.png

One more question ,as you can see from this screenshot ,number 1 is what i want ,but I don't know what caused number 2. To be honest ,i use MoBu python only a few days, i still have a lot of things to learn .Thanks again.

0 Likes
Message 5 of 6

vdebaie
Advocate
Advocate

I blieve what you want is

 

print rh.LongName

 

0 Likes
Message 6 of 6

爱贝贝
Contributor
Contributor

I want to set it to T-Pose by (this is part of the complete codes),because i have many characters to set up , and they always change

rh = FBFindModelByLabelName( myNameSpace + ":Hips" )
rh.Selected = True
rh.Selected = False
rh.Rotation = FBVector3d(90,0,0)

 but not by 

rh = FBFindModelByLabelName( 'wuchen:Hips' )
rh.Selected = True
rh.Selected = False
rh.Rotation = FBVector3d(90,0,0)

'print rh.LongName' truely get wuchen:Hips ,but it does not work with my T-Pose code.I really want to solve it.

0 Likes