Share

AcDbEntity::setLayer

C++

virtual ACDBCORE2D_PORT Acad::ErrorStatus setLayer(
    AcDbObjectId newVal, 
    Adesk::Boolean doSubents = true, 
    bool allowHiddenLayer = false
);

Description

This method sets the entity to reference the AcDbLayerTableRecord that has the object ID newVal. If the entity owns subentities and doSubents == Adesk::kTrue, then the layer change will be applied to the subentities as well. For an AcDbBlockReference entity, this method will also update any associated AcDbSequenceEnd subentity regardless of the doSubents setting.

Note

The only built-in entities for which kTrue has an effect are: AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh, and AcDbPolygonMesh.

Specifying true for allowHiddenLayer allows newVal to denote a hidden layer. If this parameter is false (default) and newVal denotes a hidden layer the change request is silently ignored, and no error is returned.

If the function is successful, then Acad::eOk is returned.

If the object with object ID newVal is not an AcDbLayerTableRecord, then Acad::eWrongObjectType will be returned.

An attempt is made to open (for read) the object identified by newVal in order to determine if it is indeed an AcDbLayerTableRecord. If the open attempt fails, then the error status returned by the failed open attempt will be returned by this function (see the acdbOpenObject() method documentation for possible return values).

Function implementation in derived classes

If this function is overridden and wishes to set the layer of the entity, then it must call AcDbEntity::setLayer() passing on the layer and doSubents arguments or call the other AcDbEntity::setLayer() passing in the doSubents value and a string which is the layer's name.

It is also possible for this function's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity::setLayer()

If this function is successful, it should return Acad::eOk. Any other error return values are up to the implementer, but if it calls either of the AcDbEntity::setLayer() methods and that call returns an error, then it's recommended that the ErrorStatus value returned be returned by this function as well.

Parameters

Parameters Description
newVal Input objectId of the AcDbLayerTableRecord to be referenced by the entity
doSubents Input Boolean indicating whether to propagate the change to any subentities the entity may own
allowHiddenLayer Input Boolean indicating whether to allow newVal to specify a hidden layer

Links

AcDbEntity

Was this information helpful?