HyperSizer Support Forum
Software Use => Scripting => Topic started by: oseresta on March 10, 2011, 04:56:25 PM
-
1. If I add any new material or a laminate. How can I make the new material or laminate definition available to my existing projects ?
2. I am creating a project thru excel VBA, I want to make certain material available to this project. How can I do that ?
Thanks
Omprakash
-
Can any one from Hypersizer please respond to the above question.
-
Omprakash,
I apologize for the delay, our Object Model expert is out of town at a training class and has not had a chance to answer this question yet. I will pass along to him that you are awaiting an answer.
Phil
-
In the COM API there is actually no notion of assigning projects to groups. You directly assign materials to groups using the VariableMaterial property of the Group class.
In VBA, create a dynamic string array. Put the laminate keys (strings) in the array, assign the array to VariableMaterial, and save.
' Print laminate keys
Dim oLam As HyperSizer.Laminate
Dim oLamCol As HyperSizer.LaminateCol
Set oLamCol = oHs.Laminates
For Each oLam In oLamCol
Debug.Print oLam.key, oLam.MaterialName
Next oLam
' Create string array of laminate keys
Dim strVarMaterial() As String
ReDim strVarMaterial(1 To 2)
strVarMaterial(1) = "20016"
strVarMaterial(2) = "20055"
' Assign string array to VariableMaterial
oGroup.VariableMaterial(vpdTopFace_ThicknessMaterial, hmtLaminate) = strVarMaterial
oGroup.Save
-
Hi
I am getting this error
Run-time error '-2147188733 (80048003)'
Unhandled Error, Application Error in Group::VariableMaterial[PropertyLet]()
Line#12, Error # 13, Type Mismatch
Dim strVarMaterial() As String
ReDim strVarMaterial(1)
strVarMaterial(0) = HS.Laminates.Item(3).Key
MsgBox (strVarMaterial(0))
Dim oProjCol As ProjectCol, oGroupCol As GroupCol
Set oProjCol = HS.Projects
Set oProj = oProjCol.Item("project01")
Set oGroupCol = oProj.Groups
Set oGroup = oGroupCol.Item(2)
MsgBox (oGroupCol.Item(2).GroupName)
oGroup.VariableMaterial(vpdTopFace_ThicknessMaterial, hmtLaminate) = strVarMaterial [In this line the debugger shows error]
oGroup.Save
Thanks for your help
-
The array you defined as two entries: strVarMaterial(0) & strVarMaterial(1).
The strVarMaterial(1) entry is not defined which causes the application error.
The VariableMaterial property will ignore the zero index array term. So to add a single material, do this instead:
ReDim strVarMaterial(1 To 1)
strVarMaterial(1) = HS.Laminates.Item(3).Key
Also, note that the array above is dimensioned using an upper and lower bound. It is best practice in VBA to define the arrays this way rather than relying on whatever default is (Option Base).
-
Thanks Ryan. It helped a lot.
One last question.
1. Is it possible to add a orthotropic material thru Object Model.
I didnt see any public method that says create for oHS.Orthotropics.#####
As per my understanding, it seems that only way to create a material is by directly using the material manager GUI. Once the materials are created, it is possible to assign or make it available to groups according to wish via COM
Please correct me if I am wrong.
-
It is possible to add a new material. To create a new material: 1) Get a reference to an existing material, 2) change the name, and 3) Execute SaveAsNew().
I will add that materials (other than laminates & layups) should be created very carefully according to your design specifications. This only has to be done once.
Materials can be imported from one database to another using File | Import. Click Advanced to import the materials.
The best way to ensure that materials are used consistently throughout an organization is to create a template database. When a new database is created, the template database (and its materials) are copied to the new database. If all team members are using the correct template database (specified in Preferences | Options) you can be sure that the correct materials and allowables are being used.
Related help topics: http://www.hypersizer.com/help/
Software Forms > Database Explorer > Project and Workspace Import Options
Software Forms > Database Explorer > Template Database
Software Forms > Utilities > HyperSizer Options
-
Thanks.
Another question
After adding a material to group, is it possible to switch the Radio button from "continuous" to "laminate" as per need from COM.
-
It's located in Group.VariableBound
oGroup.VariableBound(vpdTopFace_ThicknessMaterial, vbdLaminateOnly) = True
-
How to set "continuous" option ?
-
Set it to 'False'.
oGroup.VariableBound(vpdTopFace_ThicknessMaterial, vbdLaminateOnly) = False