I’m currently working with the sketchup C APi on a little software that would allow me to automatize the creation of several layouts on basis of a .skp file representing a wooden house.
So I use SUModelCreateFromFile (everything is fine from here) and then i want to create new layers to add to the model, but I quite don’t get how to do it.
Let’s say for example that I would like to create a layer allowing to toggle all the outer panels of the house. I Can make a std::vector containing all the component instances I need (works fine from here), but then what?
I’ve tried to create a group containing all these component instances, but i can’t add the instances to the entities of this group. (i.e. SUEntitiesAddInstance returns an error)
I’ve also tried to create one layer per panel, using SUComponentInstanceToEntity and then SULayerFromEntity, but the SUModelAddLayers won’t work…
I’m quite confused. I can provide you with some piece of my code if this can be of any help.
Good morning Dan,
First of all sorry for the reply I’ve sent on the other topic. I’m new to this forum, but I got this rule now.
Thanks for your fast answer. I guess I now have the necessary information to work it out. I’ll let you know.
Please delete the other off-topic post.
Most functions return codes. The docs tell you what the codes are. What return code did you get?
Also post a snippet showing what the code is that doesn’t work. Read this how to post code:
Thank you so much for your help!
All I needed was to cast groups or componentInstances to drawing elements, then create my layers, use SUDrawingElementSetLayer to set the tags and finally use SUModelAddLayers.
Looks completely childish now that i got it, but i’ve spent several days getting crazy with that problem.
See you, thanks again!
1 Like
You will find that it matters what order you add things. Generally after creating objects, add then to a model or one of it’s collections before you use it, and especially before you begin setting or changing it’s properties.
So I’d think it’d be safer to add the layers to the model’s layers collection, and add the drawingelement to some entities collection (that is already properly attached to the model or a definition that is already a member of the model’s definition list collection,) before layer-tagging any elements.