Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

weight of component

Status
Not open for further replies.

vitulaaak

Automotive
Jul 5, 2007
70
I used this macro from mark to assign the part properties into drawing file...
option strict off
Imports System
Imports NXOpen
Imports NXOpen.Assemblies
imports system.windows.forms

Module NXJournal

Dim thesession As Session = Session.GetSession()

sub Main
Dim thesession As Session = Session.GetSession()

Dim comp As ComponentAssembly = thesession.parts.work.ComponentAssembly
dim c as component = comp.rootcomponent
dim children as component() = c.getchildren
dim child as component
For Each child In children
dim prototype as part
if typeof child.prototype is part then
prototype = CTYPE(child.prototype,part)
messagebox.show(prototype.leaf)

end if
next
end sub


does anyone have an idea how to measure the weight of each component_? i am able to write a macro,that goes through all the components,but how to measure them???
thanks
vit
 
Replies continue below

Recommended for you


If you have advanced assemblies you will have access to the weight management system. It is under File>Properties, using the weight tab. You can also set customer defaults to have it maintained upon saving of parts.

Assemblies are assigned a mass of zero, under this system, but you could run a very conventional journal file to maintain that value possibly as an attribute, which you would then use to drive a note on the drawing.

There is also the ability to create and expression based on a mass measurement in the drawing file. I have used this in teh past and found it causes trouble when the underlying assembly content changes.

Regards

Hudson
 
Vit,

If you want to do this programmatically you need to use the command "ufs.weight.askprops(cur_part_tag,units,weight)"

If you look in the docs under uf_weight it's there.

here's an example that will return the current weight of the work part.

The weight has to be updated either manually or set to update on save under file->proporties under the weight tab.


Option Strict Off
Imports System
Imports NXOpen
imports nxopen.uf

Module NXJournal
Sub Main

Dim nxs As Session = Session.GetSession()
Dim ufs as UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()

dim cur_part_tag as tag = nxs.parts.work.tag
dim weight as ufweight.properties
dim units as ufweight.unitstype


ufs.weight.askprops(cur_part_tag,units,weight)
msgbox(weight.mass)




End Sub
End Module


Mark Benson
Aerodynamic Model Designer
 

Hi,

adding to above threads, if you need to go on an assembly in a single shot, use ufs.Weight.EstabPartProps in which the recursive flag will do the work on the contributions from the individual components of the assembly..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor