Select to view content in your preferred language

pls pls way to set block type with python

989
6
Jump to solution
08-24-2022 09:44 AM
JeoCho
by
Emerging Contributor

hi  friends 

i need help ~

pls pls pls 

i would like to set  block type.

i tried this way

 ce.setAttribute(block,'/ce/block/SKELETON',2)

ce.setAttribute(block,'/ce/block/RECURSIVE',0)

 

but not working .

how can i set block type with python ?

Tags (2)
0 Kudos
2 Solutions

Accepted Solutions
JonasObertuefer
Esri Contributor

Hi @JeoCho,

The attribute is "/ce/block/type"

And the possible values are:
"Skeleton Subdivision", "Recursive Subdivision", ... (Same as in the inspector)

If the attribute is not shown as bold in the inspector you need to not only set the value of the attribute you also need to set the source of the attribute to user.

Here is an example, I adapted it from the python docs to match your case

block = ce.getObjectsFrom(ce.selection)[0]
ce.setAttribute(block,"/ce/block/type", "Offset Subdivision")
ce.setAttributeSource(block,"/ce/block/type", "USER")

Hope this helps!

Best,
Jonas

View solution in original post

0 Kudos
JonasObertuefer
Esri Contributor

Hi again,

Sure this is also possible. You just need to change your filter from ce.isgeneratedModel (this is no valid filter!) to ce.isModel. And then select it using ce.setSelection()

 

# all generated models in scene
models = ce.getObjectsFrom(ce.scene, ce.isModel)
ce.setSelection (models)

 

Shapes which have a rule file assigned but aren't generated won't be included in the ce.isModel filter.

cheers
Jonas

View solution in original post

0 Kudos
6 Replies
JonasObertuefer
Esri Contributor

Hi @JeoCho,

The attribute is "/ce/block/type"

And the possible values are:
"Skeleton Subdivision", "Recursive Subdivision", ... (Same as in the inspector)

If the attribute is not shown as bold in the inspector you need to not only set the value of the attribute you also need to set the source of the attribute to user.

Here is an example, I adapted it from the python docs to match your case

block = ce.getObjectsFrom(ce.selection)[0]
ce.setAttribute(block,"/ce/block/type", "Offset Subdivision")
ce.setAttributeSource(block,"/ce/block/type", "USER")

Hope this helps!

Best,
Jonas

0 Kudos
JeoCho
by
Emerging Contributor

Wow wow

Really thank you , really thank you

 

Sorry , can i question one more ?

models = ce.getObjectsFrom(ce.scene , ce.isgeneratedModel)

I generate model in a certain block

And i would like to select genrated model only

Like this

models = ce.getObjectsFrom(ce.scene , ce.isgeneratedModel)

 

Is that possible ?

Sorry many ask

0 Kudos
JonasObertuefer
Esri Contributor

Hi again,

Sure this is also possible. You just need to change your filter from ce.isgeneratedModel (this is no valid filter!) to ce.isModel. And then select it using ce.setSelection()

 

# all generated models in scene
models = ce.getObjectsFrom(ce.scene, ce.isModel)
ce.setSelection (models)

 

Shapes which have a rule file assigned but aren't generated won't be included in the ce.isModel filter.

cheers
Jonas

0 Kudos
JeoCho
by
Emerging Contributor

really really thank thank thank you for  answering

i made this script 

but error, 

really really sorry  , pls can you check this 2 script 

 

1. this is script to select   ( select  generated model   in  selected block)

   but error

from scripting import *
ce = CE()

def selectblock() :
oneblock = ce.getObjectsFrom(ce.selection, ce.isBlock)
lots = ce.getObjectsFrom(oneblock[0] , ce.ismodel)
ce.setSelection(lots)
if __name__ == '__main__':
selectblock()

 

 

2  this is layer isolate script

 that is error also 


from scripting import *


ce = CE()


@noUIupdate
def main():
sele = ce.getObjectsFrom(ce.selection, ce.isLayer)
layers = ce.getObjectsFrom(ce.scene, ce.isLayer)

for layer in layers:

 

 

really  really sorry   sorry  for many ask 


layer.setVisible(False)


if sele :
sele.setVisible(True)

if __name__ == '__main__':
main()



 

0 Kudos
JonasObertuefer
Esri Contributor

Hi again,

First script:

  • There is a typo. instead of ce.ismodel you have write ce.isModel.
  • If you want to get the shapes of the block instead write ce.isShape

Second script:

Some general advice:

  • If you encounter errors check the message in the log, usually gives a good idea about what could be wrong
  • Use print statements to debug

 

Best,
Jonas

0 Kudos
JeoCho
by
Emerging Contributor

Thank you

Thank you.

thank you

0 Kudos