Help Simplfying Python Journal - Creating Datum CSYS - null?!?

Forums: 

Hi,

I am at the early stages of trying to automate generating a number of datum csys from a txt file.

For the moment I am just going to hardcode a few numbers just to understand how to even create a datum csys in NXOpen to begin with.

I recorded a journal and am trying to simplify the process and I am currently stuck with just creating a datumcsysbuilder to start.

The following are the lines I am having trouble with:


NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
NXOpen.Features.DatumCsysBuilder datumCsysBuilder1;
datumCsysBuilder1 = workPart.Features.CreateDatumCsysBuilder(nullNXOpen_Features_Feature);

As far as I am aware, there is no "null" in Python and replacing with None does not work. (I am even surprised that this is considered python given the use of semicolons and how these variables are defined.)

The closest I can get is this:


datumCsysBuilder1 = work_part.Features.CreateDatumCsysBuilder(NXOpen.Features.Feature(None))

but it complains:


NXOpen.NXException: First parameter is invalid, Object no longer exists

Thus far, the documentation that I can find suggests something that is very confusing for me. (https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx...) The CreateDatumCsysBuilders is expecting a parameter: the NXOpen.Features.DatumCsysBuilder to be edited. But if I am trying to create one, how do I give you one also?!?

Thoughts and suggestions would be much appreciated it. (Until then, I guess I will just manually create a bunch of datum csys)

Thanks,
K

"I am even surprised that this is considered python given the use of semicolons and how these variables are defined."

That is C# code, not Python. In the NX preferences -> user interface -> tools -> journal, change the journal language to Python and OK the dialog. Now NX will return Python code when you record a journal.

The Datum csys builder object requires a parameter to be passed in. If you have an existing datum csys feature that you want to edit, you pass the feature in. If you want to create a new feature, you pass in a null feature. The NXOpen API has a null type defined for you to use:

datumCsysBuilder1 = workPart.Features.CreateDatumCsysBuilder(NXOpen.Features.Feature.Null)

Thanks! Will definitely give it a try. Hopefully this resolves most of my issues and I can start being a bit more productive when it comes to Journaling in NX using Python!