Inventor Customization

Reply
Contributor
BernaJeanne
Posts: 12
Registered: ‎07-31-2008
Message 1 of 10 (344 Views)

How to flatten cylinder

344 Views, 9 Replies
07-31-2008 02:02 PM
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
*Brian Ekins \(Autodesk\)
Message 2 of 10 (344 Views)

Re: How to flatten cylinder

07-31-2008 04:00 PM in reply to: BernaJeanne
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
Contributor
BernaJeanne
Posts: 12
Registered: ‎07-31-2008
Message 3 of 10 (344 Views)

Re: How to flatten cylinder

07-31-2008 10:36 PM in reply to: BernaJeanne
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
Contributor
BernaJeanne
Posts: 12
Registered: ‎07-31-2008
Message 4 of 10 (344 Views)

Re: How to flatten cylinder

07-31-2008 11:29 PM in reply to: BernaJeanne
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
*Brian Ekins \(Autodesk\)
Message 5 of 10 (344 Views)

Re: How to flatten cylinder

08-01-2008 02:23 PM in reply to: BernaJeanne
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
Contributor
BernaJeanne
Posts: 12
Registered: ‎07-31-2008
Message 6 of 10 (344 Views)

Re: How to flatten cylinder

08-01-2008 09:28 PM in reply to: BernaJeanne
Hi Brian,

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

Thanks,
Ber
*Brian Ekins \(Autodesk\)
Message 7 of 10 (344 Views)

Re: How to flatten cylinder

08-01-2008 10:52 PM in reply to: BernaJeanne
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
Contributor
BernaJeanne
Posts: 12
Registered: ‎07-31-2008
Message 8 of 10 (344 Views)

Re: How to flatten cylinder

08-02-2008 06:35 AM in reply to: BernaJeanne
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
*Brian Ekins \(Autodesk\)
Message 9 of 10 (344 Views)

Re: How to flatten cylinder

08-02-2008 07:26 AM in reply to: BernaJeanne
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
Contributor
BernaJeanne
Posts: 12
Registered: ‎07-31-2008
Message 10 of 10 (344 Views)

Re: How to flatten cylinder

08-02-2008 10:37 AM in reply to: BernaJeanne
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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube