I define a SUSectionPlaneRef to get a cut view of a wall. I know for sure that the plane I use is correct, but still I can’t get the result I want in a layout. I’ve checked its active status with SUSectionPlaneIsActive and it is obviously not active so that would be my first guess.
So for now I have a scene with a camera placed vertically above my wall, and I can get a correct view of th top of the wall. I would like the section plane I define to be taken into account so that i can generate a “top” view of the inside of the wall.
The first thing you need to do is add the section plane object to some entities collection.
An entities collection can contain one to many section plane objects, but only one can be set active at any time.
A section plane cuts only through the entities in the same context. If you want to cut through the whole model, then add the section plane to the model’s entities collection. If you want to cut only part then group what you want to cut through and add the section plane to the group’s entities collection.
I have a .skp file representing a full house (let say house.skp) and containing an active section plane.
I make a model from house.skp, look for its active section plane and store it in a static variable (let say SUSectionPlaneRef _activeSectionPlane)
I isolate a wall in the house and save it in an other skp file (let say wall.skp) using SUComponentInstanceSaveAs
I create a model from wall.skp
I add _activeSectionPlane to this model’s entities
I set its plane to suit my needs
I create a scene with the flag set to take section planes into account
I generate a layout based on this scene much like the sample GenerateLayoutFromSkp
And then I get this soooo weird warning message: “Warning: Cannot call WriteClass/WriteObject for CObject.” and crash.
I’ve checked the return status of every single SU function calls concerned, and everything seems fine to me.
Any clue what could be going wrong? Both models from house.skp and wall.skp coexists(i.e. the first one is not yet released when i’m using the second), so _activeSectionPlane is actually present in both model’s entities.
Would that work if if I change the plane of the active section in the “house” model? I mean, if the active section in the house model intersects the wall i save in wall.skp, would the function SUComponentInstanceSaveAs also save this section?
I’m not sure what “that” is. Simply stated, geometry objects cannot be added to more than one model collection.
I’m sorry, there is no way around this. Once you add the “unowned” C API object to a model collection, it thereafter belongs to that model and it’s collection.
Unfortunately, no. The section plane is not just “in” the house model, it’s in the model’s entities collection. The wall (if it is a component) has it’s own entities collection, so doing a saveAs on the wall will not save the model’s section plane object because it’s not a member of the wall’s entities collection.
I do not know why, but the C API lacks copy / cloning functions, as well as explode functions which (if they existed) could help you greatly. We’ll just have to wait until these functions are implemented.
If you have more input or complaints, add your comments to the issue threads in the GitHub Issue Tracker for SketchUp APIs.
Your only recourse would be to create a new section plane in the wall’s entities collection and copy properties from the existing section plane in the other entities context.
But again, you are limited by the lack of an active setter function for section planes. So, (again) the only workaround I can think of is to use a component file that has an active section plane built-in, and load that component definition, create and place it’s instance as a wall component, and then add your wall geometry into it’s definition. And of course, manipulate the 2nd section plane’s properties as you need.
As I said earlier, that function has serious issues. (Ie, I would not recommend trying to use it.)
The C API really needs a correctly implemented SUComponentDefinitionSaveAs function (as it’s actually the definition that owns the geometric entities collection, not the instances.)
1) create a model from the file “house.skp”
2) remove all scenes, layers, group definitions, groups,instances and unactive section planes from this model
3) save it (using SUModelSaveToFile) into the file “template.skp”
4) create a model from this file
5) create all the instances composing the wall I want
6) generate a layout and export it to .pdf format.
Everything seems to work fine, I’m quite sure I have all the instances I need in my model, I can definitely create the layers and the scene I want, BUT:
function LODocumentExportToPDF returns the error code SU_ERROR_SERIALIZATION, no .pdf file is saved (while it worked before all this mess with the active plane).
Do you have any idea why? Are there things that need to be done for visualization after having created an instance? Any links with the materials for example?
Right now I’m trying to generate layouts directly from the original house model, but that seems rather complicated and time consuming.