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!

Problem useing mass prop volume in a DT or Equation? 2

Status
Not open for further replies.

Reily

Mechanical
Oct 11, 2007
10
This is my first thread so bear with me. (You know first long time listener, first time caller) I need to use the mass properties volume in an equation, either a DT or an equation. I need the value to solve for what I'm after. I tried setting up a custom property and useing a design table, all I got was the text in the excel file. I tried setting up an equation but all I get is an error. I don't know if I'm using the wrong text or what I'm doing. Any help would be greatly appreciated.

Thanks,
Mike
 
Replies continue below

Recommended for you

When you set up the property in the model, did the Evaluated Value field show the correct output?

[cheers]
 
Yes, I just can't seem to get thet value to show up anyplace else.
 
If you put the expression:

Application.SldWorks.GetOpenDocument("YOURPARTNAMEHERE.SLDPRT").Extension.CreateMassProperty.Mass

in an equation, it will return the mass of all existing bodies in the active configuration of the file YOURPARTNAMEHERE.SLDPRT. The part must be open in SolidWorks in its own window, although not necessarily the active window. Otherwise, according to the help, the line "may not work as expected". SW will attempt to evaluate the equation if you rebuild an assembly or drawing that references this part even if the part is not open in its own window. If you are using the equation to drive dimensions etc. then you may get some undesirable behavior. If you want the equation to work correctly no matter the context, you would need to replace the line above with:

Iif(False, CallByName(Application.SldWorks.GetOpenDocument("YOURPARTNAMEHERE.SLDPRT"),"Visible", vbLet, True), Application.SldWorks.GetOpenDocument("YOURPARTNAMEHERE.SLDPRT").Extension.CreateMassProperty.Mass)

This line will open and activate the document in its own window if it does not already have its own window. If it does have its own window, the document will not be activated.
 
Thanks for the reply, unfortuanately that didn't work. I'm thinking I must be inputing the code wrong but I'm not sure how. In the equations I put " "V"= "Application.SldWorks.GetOpenDocument(Hose2.SLDPRT).Extension.CreateMassProperty.Mass" " and it wouldn't evaluate. This has been the typical results for me. If I put " "V"= "SW-Volume@Extend@Hose2.SLDPRT" " it again says it won't evaluate but I get a -1 in the value field. Yesterday I tried what handleman told rstupplebeen about using custom props and it evaluated but when I tried to put that into an excel sheet I just got the text back not the value.
 
In this case, syntax is very important, and you have a bit of a quotation mark problem. The entire expression should not be in quotation marks, but the name of your file must be in quotation marks. So in your case, the exact text in the SolidWorks equation box should be:

"V"= Application.SldWorks.GetOpenDocument("Hose2.SLDPRT").Extension.CreateMassProperty.Mass
 
handleman,
Thanks, you're the man. I'm still having one problem. In Mass Properties it says 6.62 cu in. which seems right. In the equation though I get either .108 with ".Mass" or .000108 with ".Volume". I checked and my units are set to IPS. Is this in a default unit like cubic meters?

Thanks again,
Mike
 
Yes, the return is in cubic meters. If you multiply the .000108 result by (100^3)/(2.54^3)=61023.744 you will get your 6.62 cu in.

 
Thanks handleman. I messed with it for a while and acutally had just arrived at that when your post showed-up. I really appreciate the help. I owe you a beer (at least)!!!!!

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor