Section IDs are used to identify the specific project file a Snapper belongs to. The type of CollInfo
determines the Collaboration type that the project is in (e.g., CollInfoG3
for Collaboration G3).
This assignment is automated in normal use-cases such as inserting a Snapper from the toolbox using an Insert Animation.
Here you will find how the assignment is automated, interfaces to use, as well as examples on when and how to explicitly assign section IDs.
When Snappers are added in Collaboration, they will be assigned a Section ID via a CollInfo
instance Snapper._collInfo._sectionId
:
public class Snapper extends Entity {
... /** * CollInfo. */ private CollInfo _collInfo : ignore modify notice;
...
}
public class CollInfo { /** * Section id for collaboration. */ private symbol _sectionId;
...
/** * Getter/setter for sectionId. */ extend public symbol sectionId=(symbol id) { _sectionId = id; return _sectionId; } extend public symbol sectionId() : null=null { return _sectionId; } ... }
Snappers are assigned with IDs automatically when they are inserted into Space, i.e. assigned to the active section. The user may create new Sections and select the section they want to be active. Any Snapper they inserted from the toolbox into the drawing space will be assigned with the ID of the active section.
The assignSectionIdG3()
in Entity
(cm/core/entity.cm) is called to get a sectionID
assignment from Collaboration. This also ensures the correct CollInfo
type is used.
public class Entity extends CoreObject : modify notice, abstract { ... /** * Set section Id G3 */ extend public void assignSectionIdG3(Space space, symbol id=null) { if (space and assignCollSectionIdCBG3) assignCollSectionIdCBG3(this, ..); } ... }
Automatic assignment happens when the Snapper is inserted into Space or changed to Space.
public class Snapper extends Entity { ... /** * This snapper is inserted into 'space'. */ extend public void inserted(Space space) { ... if (!undoRestoreInProgress) assignSectionIdG3(space); if (space.isInCollWorldG3) { assignSectionIdG3(space); ... } /** * This snapper has changed space to space 'to'. */ extend public void changeToSpace(Space to) { ... if (!undoRestoreInProgress) assignSectionIdG3(space); if (to.isInCollWorldG3) { assignSectionIdG3(to); ... } ... } } }
In most cases, the automatic assignment is sufficient and taken care of, however there are cases where explicit assignment is required.
This can be done by passing the non-null id
parameter into the same assignSectionIdG3()
. (Refer to the example below Block Dialog Explode)
CollInfoG3
(or CollSpaceInfoG3
) from being assigned. This will prevent Snappers from being attached to the correct Section.
Example: Block Dialog Explode
Similar to the previous example, when the user explodes a block from the Block Dialog, they would expect the Sub-Snappers remain in the respective sections as owning BlockSnapper
. This is also achieved by calling assignSectionIdG3()
with the ID parameter. (cm/core/block/blockFuns.cm)
/** * Explode blocks. */ public SnapperSelection explodeBlockSnappers(Snapper{} blocks, bool unfreeze=false, bool selectUnfrozen=true, bool snapAligned=true) { //... for (z in sset) { // 'z' is BlockSnapper to be exploded Snapper{} snappers = copySnappers(blockSpace.snappers); ... for (s in snappers) if (s !in FloorSnapper) { ... space.undoableInsert(s, putInBsp=true); if (z.sectionId) { s.assignSectionIdG3(space, z.sectionIdG3); } ... } ... } }
Comments
0 comments
Please sign in to leave a comment.