I'm trying something new (to me) in CorelDRAW 2018, and wanted to ask if what I'm seeing is 1) expected, and 2) consistent.
I'm writing a macro to walk over pages of a CDR file and export a series of files containing only macro-selected shapes from a specific pair of layers. My CDR files have all layers locked (Editable = False) generally, as the work on the content has finished. In addition to existing Shapes, I am creating a bounding box Rectangle on the lower of the two layers, changing its outline and fill, and moving it to the bottom of that layer. This call to CreateRectangle and subsequent property changes succeed, even if the layer is non-editable. The resulting new Shape becomes selected implicitly.
However, when I tried to add existing shapes (from non-editable layers) to the selection, this failed badly. It took some time for me to figure out, as the failure was not manifesting until a call to ExportEx with cdrSelection. Eventually, I realized that the active selection was empty, and that I had cleared, but not successfully added anything to, it before trying to export. So, this has a quite simple fix/workaround. I save the initial Editable state of the layers of interest, make them Editable, do my work with selections and export, then restore the original layer state.
My fundamental question concerns the discrepancy in behavior between creating shapes and selecting shapes. If I could create a new shape on a non-editable layer (and have it implicitly selected), why can't I explicitly select shapes (via the API, of course) on those layers? I can enumerate the shapes on non-editable layers, and add them to a ShapeRange, but ShapeRange.CreateSelection fails to work (unless the layers are made Editable), but does not generate a runtime error.
On locked layers, you cannot manually create, move, or modify shapes on them. Because for this you need to first select the desired shape. Locking layer just does not allow the user to select a shape.
In addition, each shape has a parameter Selectable, that determines whether the shape can be selected or added to another selection. Depending on the conditions, this parameter can be set to false
Thanks for the reply, shark_, but that really doesn't answer my question. I'm familiar with the UI behavior of CorelDRAW back to version 5. My question was about the API behavior, which does not seem consistent with the UI behavior. In the UI, I can neither select nor create shapes on locked layers. In the API, I can create shapes, but not select existing shapes, on locked layers.
I was looking for clarification about the internal consistency of the API behavior, and the expected consistency between the UI and API behaviors.