Update physical properties of a PAR ?

 

Hi all,

I'm trying to update the Physical Properties of a document just before being saved.

I've found a solution for ASMs, with the following code (C#):

SolidEdgeAssembly.AssemblyDocument asm=(SolidEdgeAssembly.AssemblyDocument)objDocument;

asm.PhysicalProperties.Update();

This actually updates correctly the phy properties of the ASM, but it does not update its child.

Such an API is not available for PartDocument, which is rather strange.

Anyone ?

Regards,

Esteve

 

Posted by: Esteve Boix
Post date: 9/2/2009 9:16:35 PM

6 REPLIES

RE: Update physical properties of a PAR ?

 

Hi eboix,

 

you have to use ComputePhysicalProperties to update the physical properties of a part. Example below:

 

Dim Status As Integer

Dim Density, Accuracy, Volume, Area, Mass, RelativeAccuracyAchieved As Double

Dim CenterOfGravity() As Double = New Double() {}

Dim CenterOfVolume() As Double = New Double() {}

Dim GlobalMomentsOfInertia() As Double = New Double() {}

Dim PrincipalMomentsOfInertia() As Double = New Double() {}

Dim PrincipalAxes() As Double = New Double() {}

Dim RadiiOfGyration() As Double = New Double() {}

 

Density = CDbl(theDocument.Variables.Item(My.Settings.DensityVarName).Value)

Accuracy = CDbl(theDocument.Variables.Item(My.Settings.AccuracyVarName).Value)

Mass = 0

 

If theDocument.PhysicalPropertiesStatus SolidEdge.Part.Interop.PhysicalPropertiesStatusConstants.sePhysicalPropertiesStatus_User Then

theDocument.Models.Item(1).ComputePhysicalProperties(Density, _

Accuracy, _

Volume, _

Area, _

Mass, _

CenterOfGravity, _

CenterOfVolume, _

GlobalMomentsOfInertia, _

PrincipalMomentsOfInertia, _

PrincipalAxes, _

RadiiOfGyration, _

RelativeAccuracyAchieved, _

Status)

 

End If

 

Posted by: Wolfgang Kunert
Post date: 9/2/2009 9:43:23 PM

RE: Update physical properties of a PAR ?

 

I'll give a try, thanks a lot.

Anyway, it seems that I have to provide the values for each property. I just need to simulate the "Update" button.

In any case, you've opened a new path to find what I'm looking for.

Thanks a lot again for your time and help.

Regards,

Esteve

 

Posted by: Esteve Boix
Post date: 9/2/2009 10:12:23 PM

RE: Update physical properties of a PAR ?

 

Wolfgan,

Your answer was more than correct

Just for the record, I attach the C# code. This updates the Pyhsical Vars, just as if the user pressed the Update button:

-------------------------------------------------SolidEdgePart.PartDocument par=(SolidEdgePart.PartDocument)objDocument;

 

SolidEdgeFramework.variable DensityVar =

    (SolidEdgeFramework.variable)

        ((SolidEdgeFramework.Variables)objDocument.Variables).Item("PhysicalProperties_Density");

double Density=DensityVar.Value;

SolidEdgeFramework.variable AccuracyVar =

    (SolidEdgeFramework.variable)

        ((SolidEdgeFramework.Variables)objDocument.Variables).Item("PhysicalProperties_Accuracy");

double Accuracy=AccuracyVar.Value;

double Mass = 0;

 

int Status;

double Volume, Area, RelativeAccuracyAchieved;

System.Array CenterOfGravity = (System.Array)new double[]{};

System.Array CenterOfVolume = (System.Array)new double[]{};

System.Array GlobalMomentsOfInertia = (System.Array)new double[]{};

System.Array PrincipalMomentsOfInertia = (System.Array)new double[]{};

System.Array PrincipalAxes = (System.Array)new double[]{};

System.Array RadiiOfGyration = (System.Array)new double[]{};

 

par.Models.Item(1).ComputePhysicalProperties(

    Density,Accuracy,out Volume,out Area,out Mass,

    ref CenterOfGravity, ref CenterOfVolume,

    ref GlobalMomentsOfInertia,ref PrincipalMomentsOfInertia,

    ref PrincipalAxes, ref RadiiOfGyration,out RelativeAccuracyAchieved,

    out Status);

-------------------------------------------------

Best regards,

Esteve

 

Posted by: Esteve Boix
Post date: 9/2/2009 10:55:58 PM

RE: Update physical properties of a PAR ?

eboix,

 

fine that i could help you.

 

You have to check the PhysicalPropertiesStatus not to be sePhysicalPropertiesStatus_User (as i did in my sample code), which means not user defined. Else ComputePhysicalProperties will throw you an exception!

Second, the Solid Edge variable names for the accuracy and the density depend on Solid Edge's language version. They are localized! That's why i kept and retrieved the names from the application settings file.

 

Posted by: Wolfgang Kunert
Post date: 9/3/2009 1:08:17 AM

RE: Update physical properties of a PAR ?

 

Hi Wolfgang,

True, just for completeness, I'm attaching the C# translation of this part:

------------------------if(!par.PhysicalPropertiesStatus.Equals(SolidEdgeConstants.PhysicalPropertiesStatusConstants.sePhysicalPropertiesStatus_User))

{

    par.Models.Item(1).ComputePhysicalProperties(

        Density,Accuracy,out Volume,out Area,out Mass,

        ref CenterOfGravity, ref CenterOfVolume,

        ref GlobalMomentsOfInertia,ref PrincipalMomentsOfInertia,

        ref PrincipalAxes, ref RadiiOfGyration,out RelativeAccuracyAchieved,

        out Status);

}

------------------------

As for the variable names, I'm using the spanish version of SE v19, and with the SpyTool these are the names I found. I'll take a deeper look. It works as it is now, though.

Regards,

Esteve

 

 

Posted by: Esteve Boix
Post date: 9/3/2009 3:18:50 AM

Re: Update physical properties of a PAR ?

I'm just wondering...

 

AssemblyDocument.PhysicalProperties.Update(); does indeed work (at least it sems to be...), but what happens if AssemblyDocument contains parts, which does not have material at all? When doing this manually (Inspect/Properties/Update (button)) SE reports unassigned density but that line won't do anything... It just void method, and it doesn't return anything.

 

How could I make this happen through my code? I want to calculate Assembly mass and report to user that the assembly has parts, which does not have material.

 

Posted by: barbwire
Post date: 9/14/2012 5:27:52 AM