SheetMetalStyle.Thickness not set

basautomationservices
Advocate
Advocate

SheetMetalStyle.Thickness not set

basautomationservices
Advocate
Advocate

Hello all,

 

I have some code that used to run fine in older versions of inventor. Now in 2023 setting the SheetMetalStyle.Thickness property to a parameter name does not seem to work.


Anyone else had this problem?

 

My code below:

                // Find the 'default_mm' sheet metal style
                SheetMetalStyle style;
                try
                {
                    style = scDef.SheetMetalStyles["Default_mm"];
                    Logger.Info($"Retrieved sheet metal style {style.Name}");
                }
                catch (Exception ex)
                {
                    Logger.Error($"Failed to activate sheet metal style", ex);
                    throw;
                }

                // this code will not be reached if sheet metal style failed to activate
                style.Activate();
                scDef.UseSheetMetalStyleThickness = false;
                style.Thickness = thicknessParameterName;   // this does not work
Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro


0 Likes
Reply
Accepted solutions (1)
417 Views
4 Replies
Replies (4)

Michael.Navara
Advisor
Advisor

Try to change thickness parameter directly

 

//Get source values
var part = ThisDoc.Document as PartDocument;
var scDef = part.ComponentDefinition as SheetMetalComponentDefinition;
string thicknessParameterName = "MyThickness";



// Find the 'default_mm' sheet metal style
SheetMetalStyle style;
try
{
    style = scDef.SheetMetalStyles["Default_mm"];
    Logger.Info($"Retrieved sheet metal style {style.Name}");
}
catch (Exception ex)
{
    Logger.Error($"Failed to activate sheet metal style", ex);
    throw;
}

// this code will not be reached if sheet metal style failed to activate
style.Activate();
scDef.UseSheetMetalStyleThickness = false;
//style.Thickness = thicknessParameterName;   // this does not work
scDef.Thickness.Expression = thicknessParameterName; // Try this instead
part.Update2();

 

0 Likes

basautomationservices
Advocate
Advocate

Thanks for the reply Michael, for me the Thickness property is a string, not a parameter

 

basautomationservices_0-1683640927586.png

 

Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro


0 Likes

Michael.Navara
Advisor
Advisor
Accepted solution

Look at my code carefully. You need to use variable scDef not style

scDef.Thickness.Expression = thicknessParameterName; // Try this instead

 

0 Likes

basautomationservices
Advocate
Advocate

Oops.. sorry. Will try this out, thank you!

 

It works! thanks again

Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro


0 Likes