Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX9 Journal - Weight as reported in assembly navigator 1

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
I've seen this thread from 2013 which tries to answer ways to get the weight from components in an assembly.

Now I see that the weight can be reported out as a column in the assembly navigator, so I have assumed there is a simple component property that I can query in an NX Journal. However, I can't figure out what that would be.

Am I out to lunch, or is this possible? Note, I tried:
Code:
CPTMASS=ufs.weight.askprops(c.tag,units,weight)

But I just get the error that "Expression does not produce a value".

Thanks in advance,
Jeff
 
Replies continue below

Recommended for you

Try this instead:

Code:
ufs.weight.askprops(c.tag,units,weight)

The value(s) will be returned via the properties variable that was passed into the function (in this case, the one named "weight"). Be aware that the "weight" variable will need to be declared as a "UFWeight.Properties" structure as opposed to a simple "double" type variable.

www.nxjournaling.com
 
Right, that makes sense...but now I noticed that when I report weight.mass I get 0.0 for the value even though the assembly navigator shows the actual value.

I also ran the Weight Management function through the NX menus it gives me 0.0 - so from where is the assembly navigator getting the value?

Thanks,
Jeff
 
What value is returned in the "cache_state" property? If it is something other than "Cached" or "Asserted", you will need to calculate/assert the weights first (with .EstabCompProps1, .EstabPartProps1, and/or .EstabSolidProps) before asking for the result.

www.nxjournaling.com
 
Yup, it isn't cached (cache_state=0) - but then what is the navigator showing me? I guess I can't trust the navigator results...

Okay, so here is what I tried - I'm missing something again, cause it doesn't work still (it always reports "MASS NOT FOUND"):

Code:
try
[indent]ufs.weight.InitExceptions(wexpect)
ufs.weight.EstabPartProps(c.tag,0.99,1,units,weight,wexpect)
ufs.weight.askprops(c.tag,units,weight)
MASS=weight.mass
ufs.weight.FreeExceptions(wexpect)
catch e as exception
MASS = "MASS NOT FOUND"[/indent]
end try

(I don't really know what the InitExceptions and FreeExceptions are there for, I just read that I need them)

I'm also realizing that I am locking myself into having an advanced assemblies license available when running this journal...I was hoping that wouldn't be the case...

Thanks,
Jeff
 
What exception is returned? Check e.message for some more information on the exception type.

Unfortunately, I don't currently have access to an advanced assembly license to do any testing.

www.nxjournaling.com
 
Cool! I didn't even know there was an e.message property!

Anyways, it reports "SafeArray cannot be marshaled to this array type because it has either nonzero lower bounds or more than one dimension."

I commented out the other lines and just left the first one 'InitExceptions' so I would know which line is triggering. As I said, I don't even know what these are for...

Thanks,
Jeff
 
If you are using a .net language (VB, C#, etc) try using the EstabPartProps1 method (note the number 1 at the end of the name); it looks like it was added specifically for the .net languages.

API reference said:
In order to provide appropriate .NET binding for UF_WEIGHT_estab_part_props, UF_WEIGHT_estab_part_props1 is introduced.
Note: C/C++ users can continue to use UF_WEIGHT_estab_part_props

www.nxjournaling.com
 
Okay, now I'm learning something. The EstabPartProps1 got me around the weird exceptions marshaling error.

I've got it working now.

Thanks cowski!

Jeff
 
So now I've discovered another issue...one of the child components in my assembly somehow is using a different reference set for the weight management ("ENTIRE PART" instead of "PART"). So I figure, okay, I got this, just use:

Code:
ufs.weight.SetPartRefSet(child.owningpart.tag,"PART")

But it seems that unless I make this component the work part and then set the weight management reference set, it doesn't update correctly. While I guess I could make each component the work part before I set the reference set, that seems like a very inefficient way to go about the problem.

So if there are other ideas how to do this, I'm all ears.

Thanks,
Jeff
 
I have two comments:
[ol 1]
[li]The code: {component}.OwningPart is going to return a reference to the assembly part; I don't think this is what you want. To get a reference to the component part file, try: {component}.Prototype.OwningPart.[/li]
[li]The part may need to be fully loaded for the change to take effect. You can fully load all the parts by changing your load options (if necessary) or you can load them individually with the following code:
{component part reference}.LoadFully
or
{component part reference}.LoadThisPartFully[/li]
[/ol]

www.nxjournaling.com
 
Thanks again cowski! I already realized the LoadFully was needed (is there a difference between LoadFully and LoadThisPartFully?), but I didn't notice the Prototype handle was needed. Once again, that seems to do the trick.

Now if only there was a way to do this without Advanced Assemblies...sigh...

Jeff
 
The difference between .LoadFully and .LoadThisPartFully is really only important when the part that you are loading has components. The .LoadFully method will attempt to load any components according to your current load options. The .LoadThisPartFully will not load any of the components no matter what load options are currently in effect.

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor