Cancel
Showing results for 
Search instead for 
Did you mean: 

BlockStyler::ListBox::SetListItems doesn't work in Debug

Pioneer
Pioneer

Hello.

I am working with NX 11.0.0.33.

I have a dialog created with Block Styler UI that contains a NXOpen::BlockStyler::ListBox and I would like to populate this list with the names of all the Modeling Objects available. The problem is that this works as expected if the solver plugin is compiled in Release, but it doesn't work in Debug. I am not comfortable with this because I think there's a leak somewhere, but I can't find it.

 

This is the code. 

 

void DialogExportModelingObject::dialogShown_cb()
{
    try
    {
        //---- Enter your callback code here -----
	PartCollection* parts = theSession->Parts();
	BasePart* basePart = parts->BaseWork();
	CAE::FemPart* femPart = (CAE::FemPart*) basePart;

	NXOpen::CAE::ModelingObjectPropertyTableCollection modObjPropTableCollection(femPart);
	NXOpen::CAE::ModelingObjectPropertyTableCollection::iterator itModObjs = modObjPropTableCollection.begin();

	std::vector<NXOpen::NXString> listOfItems;
	NXOpen::CAE::ModelingObjectPropertyTable* theModObj;
	while (itModObjs != modObjPropTableCollection.end())
	{
		theModObj = *itModObjs;
		listOfItems.push_back(theModObj->Name());
		++itModObjs;
	}
	listModelingObjects->SetListItems(listOfItems);
		
    }
	catch (NXException& ex)
    {
        //---- Enter your exception handling code here -----
        DialogExportModelingObject::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
}

When I execute this, being compiled in Debug, sometimes I get an error: Unhandled exception encountered in callback automation code. And the dialog is not shown.

In other cases, a Microsoft Visual C++ dialog opens saying:

Debug Error!
Program: (path to ugraf.exe inside NX11 installation)
abort() has been called
.
And NX is closed.

 

In the Log, I see the following (only in Debug, of course):

+++ Area does not support very large request 18446744073708348176
*** EXCEPTION: Error code  902 in line 172 of o:\ugnx110\ip33\src\syss\sm\ind\sm_init.c at Fri Jul 14 16:29:04 2017 Romance Summer Time
+++ Bad size (2147483583) for allocation request

In Release, everything works....Any ideas? 

Thank you!

13 REPLIES

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Honored Contributor
Honored Contributor

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Pioneer
Pioneer

Indeed that post was useful to me. If I understood well, there's no way for me to use this code in debug mode, and that is by design. I can't build part of my code to MD because it is integrated with lots of classes and the separation is not easily possible.

It is good to know this, so I can't stop looking at this (unsolvable) problem...

Thank you very much for your answer!

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Honored Contributor
Honored Contributor

There is probably a solution, or at least a tenable work-around, perhaps @SteveLabout can advise...

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Pioneer
Pioneer

Hello and sorry for the direct mention out of nowhere:  @SteveLabout do you have any clue about this topic? Thanks.

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Siemens Phenom Siemens Phenom
Siemens Phenom

Sorry, I scanned the entries above, but at this point I am not completely sure what problem we are talking about.  If it is related to building NXOpen code with /MDd, the only workaround that I can suggest is to use /MD.  If you use /MDd, then your library will not be compatible with all those .DLL's in ...\ugii (or ...\nxbin, in NX11 and later.)

 

If the question is actually related to something else, please point me in the right direction.  Thanks!

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Pioneer
Pioneer

Hello and thank you for your answer. I'll explain myself better.

 

We have a solver plugin for NX. The Visual Studio 2013 solution for this plugin consist on many projects with code for different things. Some of these projects contain classes that uses NXOpen to do some stuff. For example, we have a project with a class to handle the dialog callback of an object of ours, and we do some operations with its TargetSet. In the case of this topic, it is related to a dialog created with the Block Styler UI and called from a Ribbon Bar Button, but the problem is the same: we have a class that uses NXOpen and we can't debug it.

 

When we compile the solution in debug, all the lines where we have things like: 

std::vector<NXOpen::NXObject*> v;
v.push_back(anObject);

fail and throw exceptions. In Release, everything works without problems.

 

Of course, we could compile with /MD each project that uses NXOpen, but that means compile /MD for everything because if not, we would have a mismatch in symbols (some parts would be debug, some others in release). Even so, not all the projects are isolated, we pass some data between them and if we come from a project compiled in Debug to a project compiled in Release, this will also cause an error.

This solution, as I see it, is the same as compiling directly and only in Release, which is what we are doing for the moment.

 

Maybe I'm missing something here, but that's how I see the situation.... Thank you!

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Esteemed Contributor
Esteemed Contributor

If you have multiple DLLs & projects, you need to come up with a scheme / architecture for developing them.

One option is to use different configurations in Vis Studio to compile the "production" vs. "debug" configurations.

Then have 2 different NX customization trees - one for debug, one for production.

Then use the "post build event" in visual studio to copy the DLL to the appropriate customization tree.

I'm not sure you can force every build to both configurations (in Vis Studio) but if you develop habits to "always compile to debug, then once it works, compile to production" you should always have the latest copy of every DLL available in the debug customization tree?

 

Yes, it is a pain to set up, and (initially) to get programmers to use, but once set up, debugging things should be somewhat simpler.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Pioneer
Pioneer

Hello and sorry for my late reply, I was on vacation.

I did not quite understand your suggestion. What do yo call "NX customization tree"? In the VS solution, we generate both debug and release versions, but that is the compiler configuration. Here you are talking about another thing differently. Is this something in the NX folder? I assume everything there is Release version...

 

I'm sorry, I got confused with your answer. Could you please clarify a little?

 

Thank you very much for your answer!

Re: BlockStyler::ListBox::SetListItems doesn't work in Debug

Esteemed Contributor
Esteemed Contributor

See

https://community.plm.automation.siemens.com/t5/NX-Programming-Customization-Forum/NXcustom-Utilitie...

 

I am assuming you have something similar set up (if not, you my want to consider it)

 

Set up 2 environments/trees

- NXCustom_Production

- NXCurstom_Debug

 

When you build, copy the .DLL (and/or dialog .DLX, and/or other files as appropriate) from the Vis Studio application tree to something like that.

 

When you start NX, use the appropriate environment, and all your code should be the appropriate variant.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled