CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > CoCreate Modeling

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 09-07-2014, 09:51 PM
papadam papadam is offline
Registered User
 
Join Date: Sep 2014
Location: Switzerland
Posts: 7
Multi language mass table

Hello,
I came across http://www.cocreateusers.org/forum/showthread.php?t=5234 but I would like to have the first row only in different languages.

I tried to something like this:
Code:
:contents  '(((sd-multi-lang-string "Acrylic" :german "Plexiglas")   0.043 "1.190")
What happens is in my display table I get the string "(sd-multi-lang-string "Acrylic" :german "Plexiglas")" instead of only "Plexiglas". What's wrong?

I am using Direct Modeling v17 but I think the Version does not matter much here.
Reply With Quote
  #2  
Old 09-08-2014, 06:45 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Multi language mass table

Quote:
Originally Posted by papadam View Post
Hello,
I came across http://www.cocreateusers.org/forum/showthread.php?t=5234 but I would like to have the first row only in different languages.

I tried to something like this:
Code:
:contents  '(((sd-multi-lang-string "Acrylic" :german "Plexiglas")   0.043 "1.190")
What happens is in my display table I get the string "(sd-multi-lang-string "Acrylic" :german "Plexiglas")" instead of only "Plexiglas". What's wrong?

I am using Direct Modeling v17 but I think the Version does not matter much here.
Hi,

The issue is that the sd-multi-lang-string function needs to be evaluated when populating the field. There are a couple of ways you can do this.

The first is just to use the list function rather than a quoted list, something like this:
Code:
:contents  (list (list (sd-multi-lang-string "Acrylic" :german "Plexiglas")   0.043 "1.190") ....  )
The second is to use a backquote and comma (which evaluates the immediately following function), something like this:
Code:
:contents  `((,(sd-multi-lang-string "Acrylic" :german "Plexiglas")   0.043 "1.190   .... )")
The code above is not tested, but the ideas should be accurate. Note that using the (list ...) function cannot always be used in place of a quoted list, but frequently works.

I hope this helps!

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
  #3  
Old 09-09-2014, 06:36 AM
papadam papadam is offline
Registered User
 
Join Date: Sep 2014
Location: Switzerland
Posts: 7
Re: Multi language mass table

Quote:
Originally Posted by Andy Poulsen View Post
Code:
:contents  (list (list (sd-multi-lang-string "Acrylic" :german "Plexiglas")   0.043 "1.190") ....  )
Thank you so much! This works like a charm!

Quote:
Originally Posted by Andy Poulsen View Post
Code:
:contents  `((,(sd-multi-lang-string "Acrylic" :german "Plexiglas")   0.043 "1.190   .... )")
This does not work, I get an error "a comma appeared inside a backquote" which of course is true. But no Problem since the above works.

Another issue raises up. In the thread material density settings they write
Code:
:units '( nil    :lb   Nil)
I would like to enter the density in kg/m^3 but we use kg and mm. Because we are located in different countries it's not guaranteed that everybody always has the same unit settings. How can I get the script to work independantly of the user settings?

I tried
Code:
:units '( nil    :kg/:m^3   Nil)
which does not produce an error but also does not convert the units.
Reply With Quote
  #4  
Old 09-09-2014, 07:20 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Multi language mass table

Quote:
Originally Posted by papadam View Post
Thank you so much! This works like a charm!
Excellent -- thanks!

Quote:
Originally Posted by papadam View Post
Another issue raises up. In the thread material density settings they write
Code:
:units '( nil    :lb   Nil)
I would like to enter the density in kg/m^3 but we use kg and mm. Because we are located in different countries it's not guaranteed that everybody always has the same unit settings. How can I get the script to work independantly of the user settings?

I tried
Code:
:units '( nil    :kg/:m^3   Nil)
which does not produce an error but also does not convert the units.
Density is a challenge, as it uses two units of measurement (mass and length). Modeling doesn't have a units definition for mass at the user level (it internally keeps everything in g/mm^3). This means that your logical table needs to be *created* with the values in user units.

Unit-related side note: Because Modeling doesn't automatically convert density units, I would recommend that you use a units field of nil or :number for the density field. The only reason for the units field is for automatic conversion of mass, length, and angle, as those are the units Modeling tracks. If you're not using one of those unit types in your logical table, you don't even need the :units line in your table definition.

OK, so back to the issue at hand: As I mentioned above, when you create (or modify the contents of) the logical table, you will need to have it populated with the values in user units. However, since Modeling tracks density in g/mm^3, the initial specification must be done in those units.

Perhaps the easiest way to do this is with the function sd-sys-to-user-units, which *does* allow you to convert density. If you want to convert in the other direction, use the function sd-user-to-sys-units.

So your contents line could include something like:
Code:
:contents `(("5052 Aluminum" ,(sd-sys-to-user-units :density .0027))
            ("A2 Tool Steel" ,(sd-sys-to-user-units :density .007861)))
This block uses the backquote/comma, though using (list ...) can make things a little more clear.

I hope this helps! Please let me know if you have any 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
  #5  
Old 09-10-2014, 03:23 AM
papadam papadam is offline
Registered User
 
Join Date: Sep 2014
Location: Switzerland
Posts: 7
Re: Multi language mass table

Kudos to Andy! Thanks to your help I got it to work! For the record I created a minimal example:
Code:
 (sd-create-logical-table "Material-Density-List"
  :columns '(:Material :Density)
  :columnNames (sd-multi-lang-string
      '("Material Type"  "Density in g/mm^3")
      :german
      '("Werkstoff" "Dichte in g/m^3")
      )
 :types '(:string :number)
 :contents  (list
     (list (sd-multi-lang-string "Aluminum"  :german "Aluminium") 0.098)
     (list (sd-multi-lang-string "Steel" :german "Stahl") 0.283)
      )
)
This table has the advantage you enter the relevant data only once. It works in different languages and any user units setting.

Quote:
Originally Posted by Andy Poulsen View Post
... when you create (or modify the contents of) the logical table, you will need to have it populated with the values in user units. However, since Modeling tracks density in g/mm^3, the initial specification must be done in those units.

Perhaps the easiest way to do this is with the function sd-sys-to-user-units,
Although technically possible, I would not recommend this. Most metric users have kg as their mass unit. So if you convert the units you get 0.00000... kg/mm'3 which is confusing.

I could imagine to improve the above sample with a hard coded division by 1000. So in the above example you would enter
Code:
(list (sd-multi-lang-string "Aluminum" :german "Aluminium") 9.8)
and you would still get the correct mass. Is that possible?

Last edited by papadam; 09-10-2014 at 09:41 PM. Reason: added forgotten quotes
Reply With Quote
  #6  
Old 09-10-2014, 06:29 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Multi language mass table

Quote:
Originally Posted by papadam View Post
Kudos to Andy! Thanks to your help I got it to work! For the record I created a minimal example:
Good to know -- glad it's working for you!

Quote:
Originally Posted by papadam View Post
Although technically possible, I would not recommend this. Most metric users have kg as their mass unit. So if you convert the units you get 0.00000... kg/mm'3 which is confusing.

I could imagine to improve the above sample with a hard coded division by 1000. So in the above example you would enter
Code:
(list (sd-multi-lang-string "Aluminum" :german "Aluminium") 9.8)
and you would still get the correct mass. Is that possible?
Well, since Modeling internally stores density as g/mm^3, if you're going to use the conversion function, your starting value should be in the correct units.

I'm curious why you removed the sd-sys-to-user-units functions, as I believe they will answer your question and solve your problem. As long as you specify the value in the code correctly, the user will see it displayed in their current units.

For example, you could easily do this:
Code:
 :contents  (list
     (list (sd-multi-lang-string "Aluminum"  :german "Aluminium") (sd-sys-to-user-units :density 0.0027))
     (list (sd-multi-lang-string "Steel" :german "Stahl") (sd-sys-to-user-units :density .007861))
      )
In this case, your table would display "2700" if the user's units were kg/m^3, which is a nice clean number.

On the other hand, if you want to display the values using a fixed set of units independent of the units the user is using (such as always displaying kg/m^3 regardless of user units), you can just do the conversion using a fixed factor as well rather than the sd-sys-to-user-units function. Perhaps that's what you were doing by not using the function.

Finally, you can certainly scale the values that you're adding to the table if you want to do that. Just be sure when you use the value that you scale it in the opposite direction before using it.

It's also a good idea (especially if you use units that may be different from the user's units) to make sure your column is titled appropriately to show the user what units are being used. For example, in our Volume and Mass tool, we update the titles based on the user selections (they can change the displayed unit type as part of the dialog):



I hope this makes sense. Please let me know if you have 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
  #7  
Old 09-11-2014, 01:41 AM
papadam papadam is offline
Registered User
 
Join Date: Sep 2014
Location: Switzerland
Posts: 7
Re: Multi language mass table

Quote:
Originally Posted by Andy Poulsen View Post
I'm curious why you removed the sd-sys-to-user-units functions, [...]
Dear Andy
It's a usability issue. I want to enter the values in the script using t/m^3 because this is how you have the values in mind. It creates the least leading or trailing Zeros (i.e. steel 7.8, water 1...) But this format is neither the user setting (most construction companies use kg and mm) nor the system unit setting.

Quote:
Originally Posted by Andy Poulsen View Post
On the other hand, if you want to display the values using a fixed set of units independent of the units the user is using (such as always displaying kg/m^3 regardless of user units), you can just do the conversion using a fixed factor as well rather than the sd-sys-to-user-units function.
I heard of LISP and Direct Modeling two weeks ago so I had some troubles making a simple division :-) But now I got it to work:

Code:
(sd-create-logical-table "Material-Density-List"
  :columns '(:Material :Density)
  :columnNames (sd-multi-lang-string
      '("Material Type"  "Density in kg/L")
      :german
      '("Werkstoff" "Dichte in kg/L")
      )
 :types '(:string :number)
 :contents  (list
     (list (sd-multi-lang-string "Aluminum"  :german "Aluminium") 2.75)
     (list (sd-multi-lang-string "Steel" :german "Stahl") 8.5)
      )
)
Then browse for lines containing "set_part_[...]_density" and add the division in the format (/ numerator denominator), i.e.
Code:
(sd-call-cmds (set_part_base_density :parts a_TEIL :dens (/ DICHTE 1000))
Reply With Quote
  #8  
Old 09-11-2014, 10:33 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Multi language mass table

All right! I'm glad you got it working! Lots of fun things you can do!

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
  #9  
Old 09-12-2014, 04:11 AM
Friedly's Avatar
Friedly Friedly is offline
Registered User
 
Join Date: May 2012
Location: Belgium
Posts: 76
Re: Multi language mass table

Hello,

if you want, you could have a look at
http://osd.cad.de/lisp_3d_08.htm
try the "gdm_m1_properties.lsp"

Good luck!
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 03:13 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.