CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-25-2004, 08:27 AM
Gary L. Gary L. is offline
Registered User
 
Join Date: Oct 2002
Location: Rockford, IL
Posts: 130
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
Reply With Quote
  #2  
Old 05-25-2004, 11:11 PM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
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
Attached Files
File Type: zip density_tools.zip (1.5 KB, 623 views)
Reply With Quote
  #3  
Old 05-26-2004, 03:46 AM
Gary L. Gary L. is offline
Registered User
 
Join Date: Oct 2002
Location: Rockford, IL
Posts: 130
Thanks!

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

Gary
Reply With Quote
  #4  
Old 05-26-2004, 04:48 AM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
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
Reply With Quote
  #5  
Old 05-26-2004, 05:05 AM
Gary L. Gary L. is offline
Registered User
 
Join Date: Oct 2002
Location: Rockford, IL
Posts: 130
My units are set to Inch and Lb and the report shows the results in gram/mm^3.

Gary
Reply With Quote
  #6  
Old 05-26-2004, 05:29 AM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
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
Attached Files
File Type: lsp list_density_inch.lsp (1.4 KB, 569 views)
Reply With Quote
  #7  
Old 05-26-2004, 05:51 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
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.
Reply With Quote
  #8  
Old 05-26-2004, 06:25 AM
Gary L. Gary L. is offline
Registered User
 
Join Date: Oct 2002
Location: Rockford, IL
Posts: 130
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
Reply With Quote
  #9  
Old 05-26-2004, 06:46 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
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!
Reply With Quote
  #10  
Old 05-26-2004, 06:49 AM
Gary L. Gary L. is offline
Registered User
 
Join Date: Oct 2002
Location: Rockford, IL
Posts: 130
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
Reply With Quote
  #11  
Old 05-26-2004, 07:05 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
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))
you'd want to have
Code:
(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
__________________
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!
Reply With Quote
  #12  
Old 10-10-2006, 04:20 AM
Gary L. Gary L. is offline
Registered User
 
Join Date: Oct 2002
Location: Rockford, IL
Posts: 130
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?
Attached Files
File Type: lsp list_mass_density.lsp (1.6 KB, 549 views)
Reply With Quote
  #13  
Old 07-18-2011, 06:47 AM
andrea andrea is offline
Registered User
 
Join Date: Sep 2003
Location: italy
Posts: 261
Re: Mass Properties

you can see the density of the instance?
Reply With Quote
  #14  
Old 07-19-2011, 05:04 AM
tom kirkman's Avatar
tom kirkman tom kirkman is offline
Registered User
 
Join Date: Oct 2002
Location: Perrysburg, Ohio
Posts: 397
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
Attached Thumbnails
Click image for larger version

Name:	show-density.jpg
Views:	450
Size:	70.4 KB
ID:	1801   Click image for larger version

Name:	show-details.jpg
Views:	440
Size:	18.6 KB
ID:	1802   Click image for larger version

Name:	features.jpg
Views:	451
Size:	24.6 KB
ID:	1804  
Attached Files
File Type: lsp custom_browser_views.lsp (3.9 KB, 445 views)
__________________
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.
Reply With Quote
  #15  
Old 08-01-2011, 12:25 PM
MichaelA MichaelA is offline
Registered User
 
Join Date: Feb 2006
Location: Vancouver, WA USA
Posts: 40
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
   )
 )
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:24 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.