PDA

View Full Version : Mass Properties


Gary L.
05-25-2004, 08:27 AM
Does anyone have a macro to list out the individual densities of all parts in an assembly or all loaded parts?

Thanks, Gary

jkramer
05-25-2004, 11:11 PM
Hi,

Just last week I made a tool for "drawing only" the parts in a particular density range. For example: most parts we use are either steel, aluminium or plastic. So, the density is usually between 0.0009 and 0.008. If I ask the tool to "draw only" the parts below 0.0009, no part should be visible. The same goes for a value higher than 0.008.

I also made a variant that simply lists the densities of all parts in an assy. Sorry, I don't know a simple Lisp-trick to align the density values neatly....

See the attached zip-file.

Regards,
Jaap

Gary L.
05-26-2004, 03:46 AM
Thanks!

What would I change to get it to list the densities in lb/in^3 insteed of grams/mm^3?

Gary

jkramer
05-26-2004, 04:48 AM
Hi,

you shouldn't have to worry about the units, because these are set in your system settings. So, if your OSD system is set to lb and inch, the macros will report in lb/inch.

If you want to change the default min and max value in the "show_by_density.lsp" macro, you can change them in these 2 lines:

(mindens :value-type :number :initial-value 0.007 :Title "Min.Density")

(maxdens :value-type :number :initial-value 0.009 :Title "Max.Density")

Good luck,
Jaap

Gary L.
05-26-2004, 05:05 AM
My units are set to Inch and Lb and the report shows the results in gram/mm^3.

Gary

jkramer
05-26-2004, 05:29 AM
Hi,

Sorry, yes, you are right, it seems that the Lisp-function sd-inq-part-density always works with mm and grams. WEIRD!!
I attached an lb/inch version with this reply.
Please check if I'm correct with the conversion factor....
I used 36.128.

Good luck,

Jaap

Andy Poulsen
05-26-2004, 05:51 AM
Hi,

First, one important observation -- you should change (in-package :oli) to something other than :oli -- the :oli package is one that is used for many of the OSDM functions, so there's a chance you might overwrite one of them with your own code! If you define your own package with (use-package :jtkramer) or something like that, you won't have the danger of overwriting something important! The (use-package :oli) allows you to use the exported functions from that package (i.e. functions like sd-inq-part-density).

Now to the problem at hand...

The function sd-inq-part-density will always return the value in internal units (which are mm, grams, and radians).

If you want to display in the units being used by the user, use the function sd-sys-to-user-units, which will convert from internal units to whatever units the user is using at the time. In this case, the format would be

(sd-sys-to-user-units :density (sd-inq-part-density part))

This way you don't need to do the conversions yourself!

(should this message be moved to the "Customization" forum?)

I hope this helps!

Best regards,

andy

Gary L.
05-26-2004, 06:25 AM
Thanks! That is what I wanted. I changed it to 36.1272920000837 to give better results. I also made the same change to Show By Density too.

Thanks, Gary

Andy Poulsen
05-26-2004, 06:46 AM
Hi Gary,

Actually, if you use the (sd-sys-to-user-units .... ) approach, you don't need the conversion factor at all -- it will automatically convert to whatever units you're using at the time...

This enables you to have a single function that will do what you want, regardless of what units the user is using.

Give it a look and let me know if you have any questions.

Good luck!

andy

Gary L.
05-26-2004, 06:49 AM
I saw your post after I made my last post. I am not sure where to put sd-sys-to-user-units :density in the file. Can you help me out?

Thanks, Gary

Andy Poulsen
05-26-2004, 07:05 AM
Hi Gary,

no problem!

You basically want to wrap (sd-sys-to-user-units... ) around the (sd-inq-part-density ...) call.

so for instance, instead of

(setf dens (sd-inq-part-density obj))

you'd want to have

(setf dens (sd-sys-to-user-units :density (sd-inq-part-density obj)))

This way if the user is using g/mm/rad, nothing will change, but if they're using something else, the data will be converted properly!

I hope this helps! Also, if you saw the previous message, you'll note it is important not to have (in-package :oli) at the top. In this particular case you would be safe, but you will want to protect yourself by creating your own lisp package for your own functions.

Please let me know if you have any more questions!

thanks!

andy

Gary L.
10-10-2006, 04:20 AM
I modified this lisp code to also list out the individual masses for each model. Added lines:
(setf mas (sd-sys-to-user-units :mass (sd-call-cmds(get_vol_prop :for_part obj :tol :percent_tol 10 :mass))))
(display (format nil "~6,6F : ~6,6F : ~a" mas dens (sd-inq-obj-basename obj)))

This works fine sometimes, but often the mass for the first model is repeated for all the other models. Densities are listed correctly. Anyone have any ideas?

andrea
07-18-2011, 06:47 AM
you can see the density of the instance?

tom kirkman
07-19-2011, 05:04 AM
We have a lisp program (we got this from one of the user forums I think the German forum but I do not remember.) This shows the instance and model density in the structur browser.

Load this file in your sd_customize file.

Turn on the disply by selecting features from the view selection menu. (this is a drop down menu that appears at the top right corner of the structure browser window)

If the densities do not appear, then click on show details.

Regards

Tom

MichaelA
08-01-2011, 12:25 PM
here is the function that I use all the time, lists all the densities for each part in the assembly along with the mass and then does a total for all parts at the end.

sorry for putting the code this way but the attachment stuff isn't working for me today.

Michael


(in-package :custom)
(use-package :OLI)

(sd-defdialog 'list_mass_density
:dialog-title "List Mass and Density"

:variables
'(
(ASSY :value-type :assembly
:modifies :nil
:initial-value nil
:title "Assembly"
)
(CONTAINER :value-type :boolean
:toggle-type :wide-toggle
:initial-value nil
:title "Include Containers"
)
(TOTAL :initial-value 0)
) ;; end of variables

:local-functions
'(
(recurse (obj)

(dolist (child (sd-inq-obj-children obj))
(if CONTAINER
(recurse child) ;;THEN - want everything
;;ELSE - don't want what's in the containers
(if (not (sd-inq-container-p child))
(recurse child) ;;THEN
) ;; end if for else
) ;; end of if container
) ;; end dolist

(when (sd-inq-part-p obj)
(let (
(dens (sd-sys-to-user-units :density (sd-inq-part-density obj)))
(mas (sd-sys-to-user-units :mass (sd-call-cmds (get_vol_prop :for_part :part obj :tol :percent_tol 10 :mass))))
;; 1% tol. caused error with spring model.
)
(display (format nil "~6,4F : ~6,4F : ~a " mas dens (sd-inq-obj-pathname obj)))
(setq TOTAL (+ TOTAL mas))
))
)
) ; end of local functions

:ok-action
'(progn
(display (format nil " INFORMATION ON ASSEMBLY: ~a" (sd-inq-obj-basename ASSY)))
(display " MASS : DENSITY : MODEL NAME")
(display "====== ======= ===========")
(recurse ASSY)
(display "------")
(display (format nil "~6,4F = TOTAL MASS OF ASSY ~a" TOTAL (sd-inq-obj-basename ASSY)))
(display " ") ;; separator if multiple list are generated to make easier to read on the screen
)
)