ILOGIC replace sheetmetal style

ILOGIC replace sheetmetal style

Anonymous
Not applicable
1,315 Views
4 Replies
Message 1 of 5

ILOGIC replace sheetmetal style

Anonymous
Not applicable

We have recently upgraded to 2011. The sheet metal styles have changed so much I am updating styles from old style to new style pretty regularly. Our old parts never really had a style name so the most common style name is “default”. Each part type had its own template - 16ga to 7ga in mild steel, aluminum etc... The new style library has all this information.

Could these steps be done to all parts in an assembly with ilogic code?

  1. Switch from default to new style
  2. Delete old flat pattern & create new flat pattern
  3. Purge old styles

I can change one part at a time. It would be much faster if I could put 20 or 30 parts with the same sheet metal style & run a rulle to change them all  at once.

I made a couple of attempts from older post in API but without the specific task in the provided snippets of I LOGIC code I do not have the knowledge.

SheetMetal.SetActiveStyle("styleName")

 Please help!

Thanks in advance

0 Likes
1,316 Views
4 Replies
Replies (4)
Message 2 of 5

MjDeck
Autodesk
Autodesk

There aren't any predefined iLogic functions to do this.  You would have to use the API.  I'm not sure if everything you want to do is possible with the API, but that would be your best bet.

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 3 of 5

Mike.Wohletz
Collaborator
Collaborator

I am not sure if this would work for what you are doing but just a thought on what if you use the global Styles from the styles and standards manager and then added your styles that you use to this and then you could batch them and set the global styles active. I have not had this problem since we use the global styles and have the styles located on a network drive so all the users are pulling from the same styles and if a change needs to be made all I ever do is check the boolean "osmCompDef.ActiveSheetMetalStyle.UpToDate" and if not I update it. I am thinking that if the style was in the Global Styles and standards manager then it would be easy to change to another style. the one question that I have is what is the reason for deleting the flat pattern in the part and then recreating it? it also will update to match the new style that has been activated. 

 

0 Likes
Message 4 of 5

Anonymous
Not applicable

Yes we all use 1 common network style library now, & the flat pattern is very critical.

I delete the flat pattern to get the part to the current release & retrieve extents on our idw. This only works by deleting the old flat pattern and creating a new one. This would not be a problem if  I created all new parts from scratch. This is a problem when useing an old assymbly as a template save copy as, replace component. We get all the old "default" style's in an assembly and its nice to update the new assymbly as much as possible. My old styles are all named default. the old 16 ga style is called "default" and the old 14 ga style name is "default" as well, & its been that way since R4. We had seperate templates for each thickness tied to a bend table. Now we need to get with the times.

 

 I am not to savy but very interested when it comes to programming API & ilogic. I am not sure what you mean  by chek boolean  "osmCompDef.ActiveSheetMetalStyle.UpToDate".  I would guess this code has soemthing to do with updateing to you current style libary. 

If you have anything you might like to share it would be greatly apreciated.

 

0 Likes
Message 5 of 5

Mike.Wohletz
Collaborator
Collaborator

The only way that I see this as being possible is if we look at something that is unique for each sheetmetal style, for this I am going to look at the thickness and hope that you do not have multiple styles with the same thickness as I know that I do as the bends for something like stainless are not the same as steel etc. The code that I have attached is matching the thickness from the current to the new style and setting it current and then deleting the one named "default" it it is not in use anymore. I have no iLogic for this, but I do have some vb.NET code to offer. 

 

This works for me, let me know if it will do the first part of your task and then we can move on to the second part.

 

 

    Public Sub changeStyle()
        Dim oPartDoc As PartDocument = G_oApp.ActiveEditDocument
        If oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
            Dim osmCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
            Dim currentStyle As SheetMetalStyle = osmCompDef.ActiveSheetMetalStyle
            For Each s As SheetMetalStyle In osmCompDef.SheetMetalStyles
                If s.Thickness = currentStyle.Thickness And Not s.Name.ToLower = "default" Then
                    s.Activate()
                End If
            Next
            ' we will try to delete the default style if it is local
            Try
                For Each s As SheetMetalStyle In osmCompDef.SheetMetalStyles
                    If s.Name.ToLower = "default" And Not s Is osmCompDef.ActiveSheetMetalStyle Then
                        s.Delete()
                    End If
                Next
            Catch ex As Exception

            End Try
            oPartDoc.Update()
        End If
    End Sub

 

 

 

 

0 Likes