[CONNECT U11] Dimension API

My code to add a Dimension Style from a .dgnlib to the model is failing with a return code of 32768:

pDimStyle = DimensionStyle::GetByName(L"Architectural", StyleIteratorMode::ActiveFileOnly);
wprintf(L"pDimStyle=%p, pDimStyle.IsValid()=%d, pDimStyle.IsNull()=%d\n", pDimStyle, pDimStyle.IsValid(), pDimStyle.IsNull());
if (!pDimStyle.IsValid() || pDimStyle.IsNull())
{   // DimStyle NOT in current active file
	wprintf(L"Style [%s] NOT found in the file\n", L"Architectural");
	pDimStyle = DimensionStyle::GetByName(L"Architectural", StyleIteratorMode::LibrariesOnly);
	if (pDimStyle.IsValid() && !pDimStyle.IsNull())
	{   // DimStyle FOUND in library. Save it to current file
		// add to local file
		iStatus = pDimStyle->Add();	// 32768=??
		wprintf(L"pDimStyle->Add(), iStatus=%d\n", iStatus);
	}
	else
	{
		mdlDialog_openInfoBox(L"Error: Dimension Style Name Not Found.");
		return;
	}
}

Not sure what's going on here. It seems I can CREATE a new Dimension Style and add it to the model.

Bruce

Parents
  • Hi ,

    Can you see if the test code snip below acts similar or helps?

        #include <Bentley\BeTest.h>
        ...
        DimensionStylePtr dimStyle = DimensionStyle::GetByName(L"TestDimStyle", *dgnFile);
        if(NULL == dimStyle.get())
            {
            //Create and add dimension style.
            dimStyle = DimensionStyle::Create(L"TestDimStyle", *dgnFile);
            EXPECT_EQ(true, dimStyle.IsValid());
            EXPECT_EQ(SUCCESS, dimStyle->Add());
            }

    Thank you,
    Bob



Reply
  • Hi ,

    Can you see if the test code snip below acts similar or helps?

        #include <Bentley\BeTest.h>
        ...
        DimensionStylePtr dimStyle = DimensionStyle::GetByName(L"TestDimStyle", *dgnFile);
        if(NULL == dimStyle.get())
            {
            //Create and add dimension style.
            dimStyle = DimensionStyle::Create(L"TestDimStyle", *dgnFile);
            EXPECT_EQ(true, dimStyle.IsValid());
            EXPECT_EQ(SUCCESS, dimStyle->Add());
            }

    Thank you,
    Bob



Children