Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4331

[CONNECT C++] Problem using TagElementHandler to create a tag element

$
0
0

I have installed:

MicroStation CONNECT Edition
10.15.0.74

MicroStation CONNECT Edition SDK
10.16.02.022

See my test code snippet below. 

I am getting an exception when calling TagElementHandler::Create().  Stepping in the debugger I find that tagData.IsNull() is returning true which is where I believe things are going wrong.  All the other local variables look reasonable.

Thanks,

void CreateTagTest()
    {
    DgnModelRefP dgnModelRef = MASTERFILE;
    DgnFileP dgnFileP = dgnModelRef->GetDgnFileP();

    EditElementHandle targetElement(9486, ACTIVEMODEL); // Note: 9486 is the ElementId of an element in my test dgn file

    DgnTextStylePtr textStyle = DgnTextStyle::GetActive();
    if (textStyle.IsNull())
        return;

    WString debugName = textStyle->GetName();

    ITagCreateDataPtr tagData = ITagCreateData::Create(L"tag", L"test", *textStyle, *dgnFileP);
    if (tagData.IsNull())
        return;

    RotMatrix rotation = RotMatrix::FromIdentity();
    DPoint3d loc;
    loc.Init(0, 0, 0);

    EditElementHandle tagElement;
    TagElementHandler::Create(tagElement, NULL, *tagData, *dgnModelRef, dgnModelRef->Is3d(), loc, rotation, targetElement.GetElementRef());

    DgnTagValue tagValue(PI);
    TagElementHandler::SetAttributeValue(tagElement, tagValue);

    tagElement.AddToModel();
    }

Viewing all articles
Browse latest Browse all 4331


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>