HyperSizer Support Forum

Software Use => Scripting => Topic started by: adeschenes on November 14, 2012, 12:01:00 AM

Title: Material allowables
Post by: adeschenes on November 14, 2012, 12:01:00 AM
I would like to be able to modify the material allowables (FtuL, FtyL, etc)for isotropic materials.  I can identify the material keys, but cannot find any method to tie a material of interest to the oHS.IsotropicTemperatureCol level. Is there a method to hook them up?

Thank you,
Title: Re: Material allowables
Post by: Ryan on November 14, 2012, 09:29:29 AM
Once you have the isotropic object, use isotropic.Temperatures to get a collection (Col) of all the temperature dependent data (IsotropicTemperature). I've posted a MATLAB example in the online help.

http://hypersizer.com/help/index.php#COM/Object/Isotropic.php (http://hypersizer.com/help/index.php#COM/Object/Isotropic.php)

Code: [Select]
function ModifyIsotropicMaterial(databasePath, materialName)

    hs = actxserver('HyperSizer.Application');

    while(hs.AutomationMode == false)
        hs = actxserver('HyperSizer.Application');
    end

    hs.Login('HyperSizer Admin', '');
    hs.OpenDatabase(databasePath);
   
    key = FindMaterialKeyByName(hs.Isotropics, materialName);
   
    isotropic = get(hs.Isotropics, 'Key', key);
   
    for i = 1:double(isotropic.Temperatures.Count)
       isoTemp = get(isotropic.Temperatures, 'Item', i);
       isoTemp.FtuL = 25e3; % psi
    end
   
    isotropic.Save();

end


function key = FindMaterialKeyByName(materialCol, materialName)

    for i = 1:double(materialCol.Count)

        material = get(materialCol, 'Item', i);
       
        if strcmp(material.MaterialName, materialName)           
            key = material.Key;
            return
        end           
    end
   
    error('Material was not found. %s', materialName)

end

-Ryan
Title: Re: Material allowables
Post by: adeschenes on November 14, 2012, 02:19:29 PM
Thank you.  Answers my questions. 
Title: Re: Material allowables
Post by: Neergaard on January 06, 2015, 01:09:54 PM
Gentlemen

This is a very clever trick. :) 

I have done this, and run into a unit conversion problem.  I wrote my new materials data in MKS units, and when I opened the material card in HyperSizer for browsing, I found that the units were English - (density > 4000 lbm/ft^3? ::)). 

Were I doing this manually, I would set the units toggle at the top of the page to SI before adding data.  Is there a command to script this (preferably in Matlab code)? 

Alternately, can I trust that the units will always be English if I don't intentionally set them to SI?

In other news, don't forget that the command to address a specific item in a temperature collection has changed from
isotemp = get(isotropic.Temperatures, 'Item', i) to
isotemp = isotropic.Temperatures.Item(i) in version 7.0.

-neergaard
Title: Re: Material allowables
Post by: Ryan on January 06, 2015, 08:56:10 PM
The scripting API is limited to English units only. So if you are using MKS units, it is up to you to do the conversion.

The collection semantics have change in 7.0 to make it easier for MATLAB users. Check out the 7.0 release notes for more details.
http://hypersizer.com/help/#COM/com-release_notes.php (http://hypersizer.com/help/#COM/com-release_notes.php)

-Ryan
Title: Re: Material allowables
Post by: Neergaard on January 07, 2015, 01:24:19 PM
Good to know.