#1
|
|||
|
|||
Mass Properties
Does anyone have a macro to list out the individual densities of all parts in an assembly or all loaded parts?
Thanks, Gary |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
Thanks!
What would I change to get it to list the densities in lb/in^3 insteed of grams/mm^3? Gary |
#4
|
||||
|
||||
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 |
#5
|
|||
|
|||
My units are set to Inch and Lb and the report shows the results in gram/mm^3.
Gary |
#6
|
||||
|
||||
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 |
#7
|
|||
|
|||
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
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! Last edited by Andy Poulsen; 05-26-2004 at 06:17 AM. |
#8
|
|||
|
|||
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 |
#9
|
|||
|
|||
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
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
#10
|
|||
|
|||
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 |
#11
|
|||
|
|||
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 Code:
(setf dens (sd-inq-part-density obj)) Code:
(setf dens (sd-sys-to-user-units :density (sd-inq-part-density obj))) 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
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
#12
|
|||
|
|||
Re: Mass Properties
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 ercent_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? |
#13
|
|||
|
|||
Re: Mass Properties
you can see the density of the instance?
|
#14
|
||||
|
||||
Re: Mass Properties
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
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com Last edited by tom kirkman; 07-19-2011 at 05:15 AM. |
#15
|
|||
|
|||
Re: Mass Properties
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 Code:
(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 ) ) |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|