Create a "cut list" IAM or IPT automagically

Create a "cut list" IAM or IPT automagically

DavidWHouse
Enthusiast Enthusiast
2,277 Views
9 Replies
Message 1 of 10

Create a "cut list" IAM or IPT automagically

DavidWHouse
Enthusiast
Enthusiast

I am designing a small biogas digester of a unique type. (Biogas, primarily a mix of methane and carbon dioxide, is an alternative energy source: it is natural natural gas. Biogas is the biological result of an anaerobic composting process.)

 

The digester is made primarily from polystyrene insulation welded to itself, with wood members inside and out for resisting the modest forces provided by a couple of feet of water. Plans for making these digesters are being produced via Inventor (2018, Pro). An image of the [exploded] digester is attached; further details on request.

I have used and programmed computers since 1975. I am fluent in Excel, VBA, and somewhat better than a duffer in Inventor.

I have a couple of purchased programs that will allow me to produce cut lists for the various types of standard cut lumber needed (1/4s, 1x6s. 2x4s, plywood, etc.). These programs both produce graphical views and lists that can be exported into Excel or put into CVS/TXT files, and so on.

What I would love to have is a means of taking the lists that these programs can produce and turning those-- automagically-- into some really simple IAMs or IPTs, featuring one or several standard lengths of lumber with marks to show where to make each cut. Obviously I can produce these parts or assemblies by hand, but when the design changes, then the possibility is that a lot of 'by-hand' work would get tossed into the air to land in an untidy heap.

Are there essentially non-programmatic approaches that might prove fruitful, such as connecting Inventor to Excel in order to do... [something]? Or should I be thinking about or using iLogic/VBA/C#/voodoo?

0 Likes
Accepted solutions (1)
2,278 Views
9 Replies
Replies (9)
Message 2 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @DavidWHouse,

 

Thanks for your interest in Autodesk products,

 

Wow!!! That's Awesome!!! Programming since 1975!!!

 

There are many solution to connecting excel to Inventor. Here are some useful links.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-E8EF0669-E96E-4503-8A3C-B13AB6D35DBA

 

https://www.youtube.com/watch?v=eecgf5o844M

 

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 10

tolgay.hickiran
Advisor
Advisor

hey @DavidWHouse,

here are some examples of what we do for cut lists, we take flat patterns from inventor and put those into one single autocad drawing. Our program sorts all the materials and the thicknesses of the sheet metals. 

 

1.PNG2.PNG


Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

0 Likes
Message 4 of 10

DavidWHouse
Enthusiast
Enthusiast

Chandra,

 

Thanks so much for taking the time. I actually have no trouble whatsoever connecting from Inventor to Excel, or from within Excel to Inventor. From inside Inventor, one can of course connect to an Excel SS either programmatically (using VBA or iLink for example) or by using a link from the parameters of a part or an assembly. Likewise, in fact, I can insert user parameters into a part or assembly using programming, whatever the source of the numbers (Excel, text file, keyboard, etc.).

 

So assume, please, that I can get the numbers I need into Inventor. Since I am dealing primarily with dimensioned lumber (like 2x4s), or sheet goods (like plywood), then the numbers I need for a graphical cut list are either one-dimensional (a connected set of cuts measured out from one end to the other of, say, a 10 foot 2x4), or in the latter case, a set of absolutely positioned two-dimensional numbers, which is a slightly more complex problem because one must provide not only length, but also width and (say) top-left corner position.

 

Again, then, assume I have those numbers inside Inventor, somewhere they are available and actionable: I've got that. Likewise, I can program Inventor to create, open and close files, do calculations, avoid or deal properly with errors, and so on.

 

The core question, in other words, is not about Excel, it's about what to do with the numbers that I can get into Inventor in many ways. Once they are in there, then what? How do I encourage Inventor to create IPTs or IAMs based on the parameters I have?

 

I have found some information, since I initially posted, for teaching Inventor how to make sketches using VBA, and that is much closer to what might be a solution. That is, at least for my set of problems, being able to teach Inventor to automate the process of making sketches of rectangles-- and then subsequently to extrude them individually-- would resolve my issue. If I knew enough about those particulars, then I think I could fairly easily provide the rest of what would be needed.

 

So, let me revise my initial question, to focus it more carefully. Can you tell me, please: where can I learn more about the API for sketching? Is there a well-organized and fairly comprehensive book (or books) about the API? A set of videos to recommend? 3 or 4 posts that really clarify? I don't really want to have access to one or more poorly conceived 'cut and paste' code blocks provided without surrounding information, if you please.

 

What would you recommend? 

 

d.

 

 

0 Likes
Message 5 of 10

DavidWHouse
Enthusiast
Enthusiast

 

jayjay_ice,

 

I appreciate your response. But I'm not sure I understand, sufficiently, what you mean when you say "we take flat patterns from inventor and put those into one single autocad drawing. Our program sorts all the materials and the thicknesses of the sheet metals."

 

It sounds as though you or someone has written a program which takes a set of parts, selected in some manner, creates or extracts from them some 2D information about their silhouette, further collects information about part thickness, and then creates a single drawing therefrom. Is that essentially correct? Do you consider your program proprietary? If not, could you share it here, please?

 

Thanks,

 

d.

0 Likes
Message 6 of 10

tolgay.hickiran
Advisor
Advisor
Yes david,

the we've written a 3rd party program for this and it is proprietary so i cannot share it with the public. I just wanted to show you an example of what you could do with flat patterns

Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

0 Likes
Message 7 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @DavidWHouse,

 

Actually, there is no specific Inventor Books available on API. The only reference we refer is "Inventor API documentation" comes with application.

 

It is also available at http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-5901102A-F148-4CD4-AF50-26E2AFDEE6A7

 

For practice purpose, Try the following sample VBA code which creates solid body and saves.

 

Sub Main()

    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject)

    Dim partDef As PartComponentDefinition
    Set partDef = partDoc.ComponentDefinition

    Dim oSketch As PlanarSketch
    Set oSketch = partDef.Sketches.Add(partDef.WorkPlanes.Item(2))

    Dim strPt As Point2d
    Set strPt = ThisApplication.TransientGeometry.CreatePoint2d(-1, -2)

    Dim endPt As Point2d
    Set endPt = ThisApplication.TransientGeometry.CreatePoint2d(1, 2)

    Call oSketch.SketchLines.AddAsTwoPointRectangle(strPt, endPt)

    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid()

    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = partDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kNewBodyOperation)
    Call oExtrudeDef.SetDistanceExtent("0.5 mm", PartFeatureExtentDirectionEnum.kPositiveExtentDirection)

    Dim oExtrude As ExtrudeFeature
    Set oExtrude = partDef.Features.ExtrudeFeatures.Add(oExtrudeDef)

    Call partDoc.SaveAs("C:\Temp\Plywood.ipt", False)

    Call partDoc.Close
    
End Sub

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 8 of 10

DavidWHouse
Enthusiast
Enthusiast

 

Chandra,

 

This is most excellent: Thank you! And it quite nearly gives me everything I need to have in order to fill out a solution. However, I do not quite understand the transition from adding a rectangle to the sketch:

 

Call oSketch.SketchLines.AddAsTwoPointRectangle(strPt, endPt)

To the point where one knows how to identify that newly generated object in the code in order to impose an extrude on it:

 

Set oExtrudeDef = partDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kNewBodyOperation)

In other words, between creating the sketch and doing something else with it, how can I insure that I am properly identifying a certain specific rectangle (or other created shape)? (I have not been able to find good documentation on PartFeatureOperationEnum.)

 

Given the simplicity of the approach, where only one rectangle is being created, apparently the problem is simpler, but I would love to know, when I am trying to do all this within a loop, how I can separately identify the rectangles.

 

I imagine I could stumble forward blindly and ignore the issue of identification, by simply extruding each rectangle immediately after I have sketched it. Problem solved? But inevitably that would make things more difficult at some later point if I want to extend the code in accomplish something else. Suppose I want to go back to the extruded shapes at some point and change their properties in some way. What would I do in that instance? Can I identify the rectangles by position and size, or is there a something like a GUID associated with each? What would you suggest?

 

d.

 

0 Likes
Message 9 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @DavidWHouse,

 

This is our routine coding paradigm. Try the following VBA code which is elaborated to some extent.

 

Sub Main()

    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject)

    Dim partDef As PartComponentDefinition
    Set partDef = partDoc.ComponentDefinition

    Dim oSketch As PlanarSketch
    Set oSketch = partDef.Sketches.Add(partDef.WorkPlanes.Item(2))

    Dim strPt As Point2d
    Set strPt = ThisApplication.TransientGeometry.CreatePoint2d(-1, -2)

    Dim endPt As Point2d
    Set endPt = ThisApplication.TransientGeometry.CreatePoint2d(1, 2)
    
    Dim oSketchLines As SketchEntitiesEnumerator
    Set oSketchLines = oSketch.SketchLines.AddAsTwoPointRectangle(strPt, endPt)
    
    Dim i As Integer
    i = 1
    
    Dim oSketchLine As SketchLine
    For Each oSketchLine In oSketchLines
        Debug.Print ("Line " & i & " Start point => X = " & oSketchLine.StartSketchPoint.Geometry3d.X & " Y = " & oSketchLine.StartSketchPoint.Geometry3d.Y & " Z = " & oSketchLine.StartSketchPoint.Geometry3d.Z)
        Debug.Print ("Line " & i & " End point => X = " & oSketchLine.EndSketchPoint.Geometry3d.X & " Y = " & oSketchLine.EndSketchPoint.Geometry3d.Y & " Z = " & oSketchLine.EndSketchPoint.Geometry3d.Z)
        i = i + 1
    Next

    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid()

    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = partDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kNewBodyOperation)
    Call oExtrudeDef.SetDistanceExtent("0.5 mm", PartFeatureExtentDirectionEnum.kPositiveExtentDirection)

    Dim oExtrude As ExtrudeFeature
    Set oExtrude = partDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
    
    Set oExtrudeDef = oExtrude.Definition
    
    Dim oExtent As DistanceExtent
    Set oExtent = oExtrudeDef.Extent
        
    Debug.Print ("Extruded length = " & oExtent.Distance.Expression)
    
    Call partDoc.SaveAs("C:\Temp\Plywood.ipt", False)

    Call partDoc.Close
    
End Sub

In the following link, there is a more detailed explanation on Sketches.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-311EC780-354E-4A58-9639-3E186755A498

 

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 10 of 10

DavidWHouse
Enthusiast
Enthusiast

 

Chandra,

I appreciate your time and patience. The code is useful, but what promises more help is the reminder of the API manual. I had forgotten about this resource. It is unclear in many respects, and has some problems. For example, the first two links on the page to which you directed me, "Sketches in Part Documents" and "Sketches in Drawing Documents" do not work, at all. But still, is appears to be the most comprehensive resource available.

 

The most recent code is instructive but also puzzling. It does not answer my question about how to identify unique rectangles in a sketch, but in stepping through it, I can see that when a sketch object is created, it has a Name attribute, and clearly therefore instead of thinking about uniquely identifiable rectangles within a sketch, I can think about uniquely identifiable sketches within a part, to solve the problem of later finding and manipulating rectangles, or in my instance, parts-to-cut. As such, even though you may not have answered my question, working with your code did answer it. I'm therefore marking the question as solved.

 

 

d.

0 Likes