Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to flatten cylinder

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
935 Views, 9 Replies

How to flatten cylinder

Hello guys!

How to flatten this shape? (Pls. see attached file...this is not a complete circle there is some gap). I tried the unfold method but its not working.

Thanks.
Ber
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

You'll probably have better luck asking this question in the
autodesk.inventor newsgroup, since it's a general use question and not a
programming issue.
--
Brian Ekins
Autodesk Inventor API
Message 3 of 10
Anonymous
in reply to: Anonymous

Sorry I didn't tell that it was made by a macro. Here is the last part of the macro.

Dim oShaftBody As ExtrudeFeature
Set oShaftBody = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, sOD, kSymmetricExtentDirection, kIntersectOperation)

'Convert to SheetMetal environment
If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
End If

Dim oSheetMetalCompDef As SheetMetalComponentDefinition
Set oSheetMetalCompDef = oPartDoc.ComponentDefinition

Dim oFlatPattern As FlatPattern
Set oFlatPattern = oSheetMetalCompDef.FlatPattern

oSheetMetalCompDef.Unfold

I tried this in UI, it can be flattened but i have to select first one of its surface. Unlike if i make something like square shape, selecting any face is unnecessary.

I am new to this IV programming. Pls help!

Thanks
Message 4 of 10
Anonymous
in reply to: Anonymous

Sorry I didn't tell that it was made by a macro. Here is the last part of the macro.

Dim oShaftBody As ExtrudeFeature
Set oShaftBody = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, sOD, kSymmetricExtentDirection, kIntersectOperation)
'I just copied this from the sample
'Convert to SheetMetal environment
If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
End If

Dim oSheetMetalCompDef As SheetMetalComponentDefinition
Set oSheetMetalCompDef = oPartDoc.ComponentDefinition

Dim oFlatPattern As FlatPattern
Set oFlatPattern = oSheetMetalCompDef.FlatPattern

oSheetMetalCompDef.Unfold

I tried this in UI, it can be flattened but i have to select first one of its surface. Unlike if i make something like square shape, selecting any face is unnecessary.

I am new to this IV programming. Pls help!

Thanks
Ber
Message 5 of 10
Anonymous
in reply to: Anonymous

There's an Unfold2 method that allows you to specify the base face for the
unfold. Here's the sample I used to test it for your case.

Public Sub UnfoldCylinder()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument

Dim oSMDef As SheetMetalComponentDefinition
Set oSMDef = oPartDoc.ComponentDefinition

' Find one of the cylindrical faces of the part.
Dim oFace As Face
For Each oFace In oSMDef.SurfaceBodies.Item(1).Faces
If oFace.SurfaceType = kCylinderSurface Then
Exit For
End If
Next

Call oSMDef.Unfold2(oFace)
End Sub

--
Brian Ekins
Autodesk Inventor API
Message 6 of 10
Anonymous
in reply to: Anonymous

Hi Brian,

I tried the code but it seems UNFOLD2 is not supported in IV 2008. Is there any workaround on this?

Thanks,
Ber
Message 7 of 10
Anonymous
in reply to: Anonymous

You're right. That method is new for Inventor 2009. A workaround is to
drive the command through the API. It happens to be easy in this case
because the only input is to pre-select a face. The downside to doing this
is that the document needs to be visible and active. Here's the modified
code.

Public Sub UnfoldCylinder()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument

Dim oSMDef As SheetMetalComponentDefinition
Set oSMDef = oPartDoc.ComponentDefinition

' Find one of the cylindrical faces of the part.
Dim oFace As Face
For Each oFace In oSMDef.SurfaceBodies.Item(1).Faces
If oFace.SurfaceType = kCylinderSurface Then
Exit For
End If
Next

oPartDoc.SelectSet.Clear
oPartDoc.SelectSet.Select oFace
ThisApplication.CommandManager.ControlDefinitions.Item("SheetMetalFlatPatternCmd").Execute
End Sub

--
Brian Ekins
Autodesk Inventor API
Message 8 of 10
Anonymous
in reply to: Anonymous

Hi Brian!

I tried the new code but I am getting an error msg. Please see the attached error msg. I checked the default thickness and the model thickness, they are the same.

What I understand with the code is that; it is equivalent in the UI by selecting one of its cylindrical face before clicking the "Flat Pattern" icon, right? Because, if I do this manually the cylinder is flatten.

Please give me an idea what causing this error msg.

Thanks
Ber
Message 9 of 10
Anonymous
in reply to: Anonymous

My program just looks for the first cylindrical face it finds in the model.
I don't know exactly what your model looks like but possibly it's picking a
cylinder that's not valid for the starting face. If you debug and put a
break in the code just before it executes the command you can see in the
graphics window which cylinder is selected. You might need to improve the
logic on how it finds a cylinder. Without knowing more about your specific
model or workflow I can't really offer any suggestions.
--
Brian Ekins
Autodesk Inventor API
Message 10 of 10
Anonymous
in reply to: Anonymous

Hi Brian.
I solved the problem! Thank you for your time and suggestions. It helps a lot!

I attached the final output of the program.

Thanks,
Ber

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report