In my DgnElementSetTool, I'm placing a cell at the projection of the cursor to the picked element. The cell gets placed, but the association is not correct - the cell has a dashed outline. What am I missing? I can successfully create a Dependency Linkage, but not an AssociativePoint....
private: StatusInt _OnElementModify(EditElementHandleR eeh) override { DgnButtonEvent ev; GetCurrentDgnButtonEvent(ev); EditElementHandle eehCell(m_masterCell, true); // copy the original cell if (CreateSymbol(eehCell, ev)) { AssocPoint assocPoint; AssociativePoint::InitOrigin(assocPoint, 0);//0=default, 1-9= LL, UL, UR, LR, CL, UC, CR, LC, CC, can be used for element types: cell headers, shared cells, text nodes and text elements. if (AssociativePoint::IsValid(assocPoint, eeh.GetDgnModelP(), eehCell.GetDgnModelP())) { BentleyStatus bStatus = AssociativePoint::SetRoot(assocPoint, eeh.GetElementId(), 0); StatusInt iStatus = AssociativePoint::InsertPoint(eehCell, assocPoint, 0, 1); eehCell.AddToModel(); } } return SUCCESS; }
Bruce Reeves SRNS said:What am I missing?
AssociativePoint::SetRoot(assocPoint, eeh.GetElementId(), 0);
Check that the copy of the cell has a valid ID and DGN model. I don't know the internal order of things, but you may have to add the cell copy to the model to obtain a valid ID and model reference, then do the associative stuff and finally rewrite the element.
Regards, Jon Summers LA Solutions
If I add the copied cell (AddToModel()) prior to creating the AssociativePoint, and then use ReplaceInModel() after inserting the point into the cell, I get a return status of 32768, so something is still wrong. The placed cell gets no linkage. When do as described above, I at least get a linkage (an invalid one, but at least a linkage gets attached).
A working example would be very helpful, as I have not been able to find one either in the Communities or the delivered examples.
Bruce
Bruce Reeves SRNS said:A working example would be very helpful
Does this thread help?
This works for me, but I have an existing element …
AssocPoint assocPoint; AssociativePoint::InitOrigin (assocPoint, 0); AssociativePoint::SetRoot (assocPoint, host.GetElementId (), 0, 0); TextHandlerBase::SetupOffsetAssociation (label, host, assocPoint);
Thanks, but your example doesn't directly apply - I'm trying to associate a cell origin to a location on an element. I've got an existing element picked by the user, that is passed into _OnElementModify(). The cell element is "in memory" (dynamically), displayed with it's origin aligned to the cursor location, and has not yet been added to the model. The _OnElementModify() function does the following:
AssociativePoint::InitOrigin(assocPoint, 0);//0=default, 1-9= LL, UL, UR, LR, CL, UC, CR, LC, CC, can be used for element types: cell headers, shared cells, text nodes and text elements. BentleyStatus bStatus = AssociativePoint::SetRoot(assocPoint, eeh.GetElementId(), 0, 0); StatusInt iStatus = AssociativePoint::InsertPoint(eehCell, assocPoint, 0, 1); eehCell.AddToModel();
which places the cell into the model, and creates an "invalid" Association. If I alter the code slightly:
eehCell.AddToModel(); AssociativePoint::InitOrigin(assocPoint, 0);//0=default, 1-9= LL, UL, UR, LR, CL, UC, CR, LC, CC, can be used for element types: cell headers, shared cells, text nodes and text elements. BentleyStatus bStatus = AssociativePoint::SetRoot(assocPoint, eeh.GetElementId(), 0, 0); StatusInt iStatus = AssociativePoint::InsertPoint(eehCell, assocPoint, 0, 1); eehCell.ReplaceInModel(eehCell.GetElementRef());
the cell places in the model, but no Association Linkage is created. Still not sure what I'm missing. I did find an earlier thread (+5 yrs ago) in which Brien Bastings suggested using mdlAssoc_getPoint() and use that position to "move" the cell (again) prior to calling ReplaceInModel(). That didn't work either.
Bruce Reeves SRNS said:Brien Bastings suggested using mdlAssoc_getPoint() and use that position to "move" the cell (again) prior to calling ReplaceInModel().
The place cell tool does evaluate the assoc point location and use it to update the cell origin before adding the cell to the model (there's to need to add then call replace)...
What is likely happening is that the assoc point dependency callback is firing and it's failing the association because the cell wasn't created at the location of the assoc point, yet no dependency roots are changed to require updating the cell's location.
-B
Brien Bastings said:What is likely happening is that the assoc point dependency callback is firing and it's failing the association because the cell wasn't created at the location of the assoc point, yet no dependency roots are changed to require updating the cell's location.
So there's no way to add an Association Point? Since this initial post, I have moved forward and implemented a Dependency Linkage on the element that will enable me to achieve the necessary association. Still would like to know if it's possible to add an Association Point...
Yes, it's possible, the place cell tool does it using the steps I mentioned.