SubdivideShapesSettings - setLotSubdivisionMethod

1929
3
11-14-2011 05:37 AM
Jackde_Valpine
New Contributor
Hi,

I am working on a python script that subdivides blocks (imported) based on some different parameters. To set the parameters I am using the SubdivideShapeSettings methods. Some of these class methods do not appear to exist, such as setLotSubdivisionMethod? Following is the function that I have defined:

[INDENT]def subdBlock(name):
    subds = SubdivideShapesSettings()
#    subds.setCornerAlignment('STREET_LENGTH')
    subds.setCornerAngleMax(90.0)
    subds.setCornerWidth(0.0)
    subds.setForceStreetAccess(0.0)
    subds.setIrregularity(0.3)
    subds.setLotAreaMax(1500.0)
    subds.setLotAreaMin(500.0)
    subds.setLotElevation("EVEN_MIN")
    subds.setLotMinWidth(10.0)
    subds.setSubdivisionRecursive("True")
    subds.setOffsetWidth(25.0)
#    subds.setSeed(0)
#    subds.setShallowLotFrac(1.0)
#    subds.setSimplify(4.0)
#    subds.setLotSubdivisionMethod("OFFSET")
    ce.subdivideShapes(name, subds)[/INDENT]

The commented items generate errors when I try to include them.

I am running CityEngine 2010.3 build 0124 (release, win32-64bit).

Thanks,

-Jack de Valpine

PS, Note I have tried to see if this has been addressed in the forum archives. However, I am relatively new to City Engine, so if this is FAQ or otherwise documented somewhere please point me in the right direction!
Tags (3)
0 Kudos
3 Replies
AndreasUlmer
Occasional Contributor
not fully sure what you mean by
"The commented items generate errors when I try to include them."

does that mean when executing the script, or even before?

The script you sent parses fine for me. One thing that could be unclear:

you are calling the subdivide function with the param name.
ce.subdivideShapes(name, subds)


how does your function call look like? are you calling subdBlock(name) with name being a string name (e.g. "MyShape")? That would not work. You need to put a list of shapes as parameter.


So I recommend to rename
def subdBlock(name):
  ...
  ce.subdivideShapes(name, subds)


to

def subdBlock(shapes):
  ...
  ce.subdivideShapes(shapes, subds)



and calling it for example with
shapes = ce.selection()[0]  ## the first object in the selection
subdBlock(shapes)


assuming you have a shape selected.
0 Kudos
Jackde_Valpine
New Contributor
Hi Andreas,

Thanks for the follow-up!

The argument <name> that is being passed to the function is a shape.

The issue that I noticed is that several of the shape settings do not seem to work/exist, eg setCornerAlignment, setSeed, setShallowLotFrac, setSimplify, setLotSubdivisionMethod. These class methods are all listed in the on-line documentation so it is puzzling. I did discover that there is a method: setSubdivisionOffset which is really what I thought I wanted out of setLotSubdivisionMethod. So I do have a scripted block subdivision working (note this is for static imported block shapes).

Thanks,

-Jack
0 Kudos
BenLeslie1
Regular Contributor

I too am having difficulty defining the subdivide settings using Python.  I'm attempting to do a select by attribute followed by a subdivide - similarly to Jack de Valpine the code works with some subDivide settings defined, but when I add other settings (such as setSimplify) the code does not work.  Does it matter what order settings are defined?

Here's my code - I must say I've only really worked with arcpy before and I'm finding this code a little alien:

def selectByAttribute(attr, value):

    objects = ce.getObjectsFrom(ce.scene)

    selection = []

    for o in objects:

          attrvalue = ce.getAttribute(o, attr)

          if attrvalue == value:

              selection.append(o)

    ce.setSelection(selection)

selectByAttribute("buildCat", "Residential")

shapes = ce.getObjectsFrom(ce.selection())

divset = SubdivideShapesSettings()

divset.setLotAreaMin(200)

#divset.setIrregularity(0)

#divset.setSimplify(1)

#divset.setLotSubdivisionMethod("SKELETON")

ce.subdivideShapes(shapes, divset)

0 Kudos