Select to view content in your preferred language

setting startRule when using PyPRT

856
2
08-01-2023 10:15 AM
Mateo_Neira
Occasional Contributor

I'm trying to create OBJ's using the python bindings for the procedural runtime. I have 4 shapes and I want different shapes to be generated using different rules defined in my CGA - I would normally do this by setting the startRule as an attribute of the shape. 

It seems that pyprt does not support setting a StartRule file anymore? this used to be a parameter that could be set for each shape. 

 

as an example I have:

Using the pyprt I've tried to use the shape attributes for this:

 

shape_attributes = [
    {'shapeName': 'left_lot', 'seed': seed, "startRule": "Lots"},
    {'shapeName': 'left_sidewalk', 'seed': seed, "startRule": "Sidewalks"},
    {'shapeName': 'street', 'seed': seed, "startRule": "Street"},
    {'shapeName': 'right_sidewalk', 'seed': seed, "startRule": "Sidewalks"},
    {'shapeName': 'right_lot', 'seed': seed, "startRule": "Lots"}
]
 
#prt_shapes is a list containing 5 pyprt shapes
model_generator = pyprt.ModelGenerator(prt_shapes)
 
#my rpk with the different rules which I want to use as startRules
rpk = os.path.join(cwd, 'model.rpk')
 
encoder = 'com.esri.prt.codecs.OBJEncoder'
 
encoder_options = {
        'meshGranularity': 'AS_GENERATED',
        'vertexNormals': 'SET_ALL',
        'baseName': "street",
        'outputPath': cwd
        }
 
generated_models = model_generator.generate_model(
        shape_attributes,
        rpk,
        encoder,
        encoder_options
    )
 
 When I run this, all models are generated using the default StartRule defined in my CGA rather than the one specified by the shape parameters. 

 

 

 

0 Kudos
2 Replies
SimonHaegler
Esri Contributor

Hi Mateo,

we removed support for explicitly setting the start rule in PyPRT 1.1 (2020), there were some problematic edge-cases (styles) and we aimed for simplicity.

How about introducing a "dispatcher" start rule which calls the desired rule based on an (enum) attribute? If you do not want to modify your existing "model" rule you could put the dispatcher into a separate rule file and use import.

Best,
Simon

0 Kudos
Mateo_Neira
Occasional Contributor

Hi Simon,

I did end up doing a similar approach to a dispatcher rule and that's all working. Thanks for the suggestion. 

Best,

Mateo