Showing posts with label metal. Show all posts
Showing posts with label metal. Show all posts

Friday, 9 December 2016

Part Number on Flat Pattern

I’ve told you before I like helping out on Autodesk Answer Days and it’s good to keep an eye on that when it happens.




That’s when you get some of the best questions because a lot of people have done the research, know there is no solution available unless an Autodesk employee looks at the code and provide the insight or blends a quick bit of code for your problem.

As I am aware not all of you have the time for it I try and share the best, rare, exceptional that catches my attention

                Exactly this case for the question “How to get Part Number on Flat Pattern”.

                Seems we have covered this before and you are correct to think this but it was a bit different for we have showed how to do that from the drawing using a symbol note before the export; you can read it all again here.

                But this is different for what he wants is to have the part number on the flat pattern in the model and I am guessing that is because he wants to do emboss it, cut it out or just have it as a text on his flat pattern exports.

                You know you can export the flat pattern or just a face, right?

                Right click on Flat Pattern and choose Save Copy As with sat, dxf, dwg as output or right click on a face and choose Export Face As with dxf, dwg as output.

               
Flat Pattern Save Copy As..



Export Face As

                The solution is simple brilliant and Cai from Autodesk has provided the answer.  Create a sketch on flat pattern face with a text in it and the code bellow will change that text to Part Number. All you need to do is run the iLogic code and watch the magic taking place.
               
Dim oDoc As PartDocument
 oDoc = ThisApplication.ActiveDocument
 
Dim oDef As SheetMetalComponentDefinition
oDef = oDoc.ComponentDefinition
 
Dim oSK As Sketch
oSK = oDef.FlatPattern.Sketches(1)
 
osk.TextBoxes(1).Text=iProperties.Value("Project", "Part Number")

How good is that? Because I find it brilliant.        

         Of course the user needed some more; as it happens with this things and we jumped right back to help him out.

         What if there is no sketch on flat pattern? Can I prompt the user to create it?

         Cai replied:

If oDef.FlatPattern.Sketches.Count >0 Then
 oSK = oDef.FlatPattern.Sketches(1)
Else
 ' There is no sketch
End If


And I (late as usual) told him to use a try/catch; here is the complete code:


Dim oDoc As PartDocument
 oDoc = ThisApplication.ActiveDocument
 
Dim oDef As SheetMetalComponentDefinition
oDef = oDoc.ComponentDefinition
 
Dim oSK As Sketch
Try
    oSK = oDef.FlatPattern.Sketches(1)
    osk.TextBoxes(1).Text=iProperties.Value("Project", "Part Number")
Catch
    MessageBox.Show("Sketch not found" _
                    & vbLf & "Please crete a sketch first", "No sketch")
    
End Try


Later,
ADS photo credit: Panoramas Washington - National Gallery of Art - Calder - 8-11-2014 - 17h18 (license)

Thursday, 15 September 2016

Convert Parts to Sheet Metal

Still slow on picking up old habits and I am ridiculously busy at work. I think they wouldn’t mind if I get a bed in the office and move in completely.

The other day I started investigating how to convert a batch of parts to sheet metal? If you have a lot of files you might want to use code injector from here. This will insert the code in the files, run it and then remove it from the files cleaning them up.

layers upon layers..



The code to use is.

---------------------------------------------
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
 
'Change Document.SubType to Sheetmetal
oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

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

But what if have an assembly open and I want to convert specific parts? This code will allow you change parts to sheet metal from within the assembly. As long as you don't press ESC and you keep selecting parts in the graphical window it will convert them to sheet metal parts.


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

Dim oADoc as AssemblyDocument
oADoc = ThisApplication.ActiveDocument
 
Dim comp As Object
 
While True
    'prompt user to select an occurrence
    comp = ThisApplication.CommandManager.Pick(
        SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, 
        "Select a component") 
    If comp Is Nothing Then
        MessageBox.Show ("Selection was cancelled","ilogic")
        Beep
        Exit While
    End If
    
    oPartDoc = comp.Definition.Document
    
    Try
        oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
    Catch
        MessageBox.Show("Some error occurred, make sure it's not read-only or library item","error")
    End Try
 
End While

----------------------------------------------
Here’s a short animation.


convert to sheet metal

And then you might ask how to change thickness while we’re here?
This presented a problem in itself because the thickness parameter can’t be accessed directly and the end value seemed to be 10x bigger..!
I read somewhere that the default Inventor units are cm and I needed them in mm but don’t take my word for it.

Here is the code with prompted thickness value.

 ----------------------------------------------
Dim oADoc as AssemblyDocument
oADoc = ThisApplication.ActiveDocument
 
Dim comp As Object
 
 
While True
    'prompt user to select an occurrence
    comp = ThisApplication.CommandManager.Pick(
        SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, 
        "Select a component") 
    If comp Is Nothing Then
        MessageBox.Show ("Selection was cancelled","ilogic")
        Beep
        Exit While
    End If
    
    oPartDoc = comp.Definition.Document
    
    Try
        oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
        
        Dim oSheetMetalCompDef As SheetMetalComponentDefinition
        oSheetMetalCompDef = oPartDoc.ComponentDefinition
        
        ' Override the thickness for the document
        oSheetMetalCompDef.UseSheetMetalStyleThickness = False
        
        ' Get a reference to the parameter controlling the thickness.
        Dim oThicknessParam As Parameter
        oThicknessParam = oSheetMetalCompDef.Thickness
                
        
        'promot user to enter thickness
        'this will get current and ask for new one
        Dim oNewTHK As Double
        'read that default units are cm need to get them to mm
        'but I suspect this is to do with not pecifying explicitly units
        oNewTHK = InputBox("Enter Thickness", "iLogic",oThicknessParam.Value) 
        ' Change the value of the parameter.
        oThicknessParam.Value = oNewTHK/10
    Catch
        MessageBox.Show("Some error occurred, make sure it's not read-only or library item","error")
        Exit While
    End Try
 
End While

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

Later,
ADS

photo credit: DC-3 (license)

Wednesday, 15 October 2014

Sheet metal imports

Let me drop a couple of words on getting flat patters from imported components. I've seen a lot of imported parts lately created in other cad packages (Catia in this case) with punches that Inventor has problem creating flat pattern for.

The secret here is to use delete face with heal on and delete the inside of the punch first and only afterwards the outside faces of the punch in a separate delete operation. You can select inside faces of all punches for your first delete face operation.






If your vendor exported an assembly with one part, Inventor will imported it as multi-body part with one body and it will complain that it can't be converted to sheet metal.

In this case you can export it again to a neutral file format and import that back or you can use derive to get it all as one body.

I have a test model for you made with Inventor 2014 where you can try these out.

When you try and convert to sheet metal you will see that inventor complains about having multiple bodies so we need to derive it into a single body.

1. Open a new part.

2. Go to 3d model / create/ derive and browse to our file : 141017 Sheet metal imports.ipt

3. In the derived part dialog, expand solid bodies, and unmark Body.1 (you only need to have Body.13)

4. On the derived style select single solid body and click ok.





Even though we have only one body it seems that the round inserts at the end of the arms are modeled in so we need to remove them to a constant thickness part.

5. Extrude-cut the sheet metal nuts (round inserts)


6. Select the inside faces of the punches, one at a time or all at once. Start the delete face operation and after marking heal option click ok. You should have something as in the images bellow.





 7. Repeat the operation again for the outside faces of the punches. The end result should be like this:





 8. Verify the thickness and change it accordingly in the sheet metal options.

9. Use flat pattern. You might need to select one face (inside face) before flat patterning if it doesn't unfold. You might also need to delete the existing flat pattern if any to get it to compute.



And of course a video.



ADS