Howto create layerobject

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 22/07/2009 at 14:39, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   10.5 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------

Howto create LayerObject?

First wrong

> BaseObject\* lay = BaseObject::Alloc(Olayer); \> (!lay) return FALSE;     // return null pointer \> lay->SetName(LayNameString); \> doc->InsertObject(lay,NULL,NULL,FALSE);

Second wrong

> LayerObject\* lay = LayerObject::Alloc(); \> (!lay) return FALSE;     // Good \> lay->SetName(LayNameString); \> doc->InsertObject((BaseObject\* )lay,NULL,NULL,FALSE);//Crash

Please help.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 22/07/2009 at 14:56, xxxxxxxx wrote:

Hi dinnye,

The LayerObject has nothing to do with BaseObject. See class hierarchy.

What you want to do?

Bye, Sebastian

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 22/07/2009 at 15:12, xxxxxxxx wrote:

Hi Shawni

I want create layer in the Layer Browser (and assign to object (later))

My code

> Bool AC4DPOLY::CreateLayer     (BaseDocument \*mydoc, String LayNameString) \> { \>      GeListHead \*layerlist = NULL; \>      layerlist = mydoc->GetLayerObjectRoot(); \>      if(!layerlist) return FALSE; \>      Bool laycheck =TRUE; \> \>      //check current layerlist \>      LayerObject \*layer = (LayerObject\* )layerlist->GetFirst(); \>      if (layer) \>      { \>           for (layer; layer; layer = layer->GetNext()) \>           { \>                if (LayNameString == layer->GetName()) \>                { \>                     laycheck = FALSE; \>                     break; \>                } \>           } \>      } \> \>      //Create layer \>      if (laycheck) \>      { \>           //Create layer with LayNameString name; \>      } \> \>      return TRUE; \> }

Dont know howto alloc LayerObject, not sample in SDK.
Sorry my bad english.

Thanks
Dinnye

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 22/07/2009 at 16:18, xxxxxxxx wrote:

LayerObject* lo = LayerObject::Alloc();
if (!lo) // allocation failed

I see you tried doc->InsertObject(). You probably need to get the layer root (doc->GetLayerObjectRoot()) and append to the list (GeListHead->InsertLast(lo)).

Set an object to the layer using obj->SetLayerObject(lo).

Use lo->GetLayerData(doc,...) to get the layer settings.

About all that I can tell you about layers. 😄

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/07/2009 at 01:12, xxxxxxxx wrote:

Thanks. Try this.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/07/2009 at 02:05, xxxxxxxx wrote:

Yes, you have to insert the layer into the layer's list.

Simple example, inserts a layer:

> \> Bool MenuTest::Execute(BaseDocument \*doc) \> { \>      LayerObject \*layer = NULL; \>      layer = LayerObject::Alloc(); \>      if (!layer) return FALSE; \> \>      GeListHead \*layerlist = NULL; \>      layerlist = doc->GetLayerObjectRoot(); \>      if (!layerlist) return FALSE; \> \>      layerlist->Insert(layer, NULL, NULL); \> \>      layerlist->Message(MSG_UPDATE); \> \>      EventAdd(); \> \>      return TRUE; \> } \>

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/07/2009 at 03:26, xxxxxxxx wrote:

wow, cool!

Thanks Matthias.