flatpattern drawing

DWhiteley
Advisor
Advisor

flatpattern drawing

DWhiteley
Advisor
Advisor

Using the sample code below, how do I show the bend lines on the drawing view?

 

Thanks in advance, Dave

 

Public Sub AddFlatPatternDrawingView()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet

    ' Create a new NameValueMap object
    Dim oBaseViewOptions As NameValueMap
    Set oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

    ' Set the options to use when creating the base view.
    Call oBaseViewOptions.Add("SheetMetalFoldedModel", False)

    ' Open the sheet metal document invisibly
    Dim oModel As Document
    Set oModel = ThisApplication.Documents.Open("C:\temp\SheetMetal.ipt", False)

    ' Create the placement point object.
    Dim oPoint As Point2d
    Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25)

    ' Create a base view.
    Dim oBaseView As DrawingView
    Set oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1, _
    kDefaultViewOrientation, kHiddenLineRemovedDrawingViewStyle, _
    , , oBaseViewOptions)
End Sub

 

0 Likes
Reply
559 Views
10 Replies
Replies (10)

adam.nagy
Autodesk Support
Autodesk Support

Hi Dave,

 

I think the best thing is always to try things in the UI and then examine the result in VBA Watches window:

http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html

 

I assume you mean the "Bend Extents" option of the DrawingView. That only seems to be available when you place a Flat Pattern - you are placing a Folded Model:

SheetMetal.png

 

If the option is available then it can be set using DrawingView.DisplayBendExtents

 

Cheers, 

 



Adam Nagy
Autodesk Platform Services
0 Likes

o.sassen
Participant
Participant

Hi, 

 

I would like to place a base view of folded model. 

 

 

' Set the options to use when creating the base view.
Call oBaseViewOptions.Add("SheetMetalFoldedModel", True)

 

I have tried this, but with no succes. 

Can anybody tel me how to create the folded model, isometric view. 

 

Thank you! 

 

0 Likes

MechMachineMan
Advisor
Advisor

1. This is an old post. Please make a new post instead of reviving old threads.

 

2. What isn't working about it? Where is the full section of code to see what you are doing wrong? That single line you typed looks just fine. How it's used in the larger program may be a different story.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @o.sassen,

 

I tried the following sample VBA code with attached part. Before running this code, make sure that a drawing document is opened in Inventor 2018.

 

Public Sub AddFlatPatternDrawingView()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet

    ' Create a new NameValueMap object
    Dim oBaseViewOptions As NameValueMap
    Set oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

    ' Set the options to use when creating the base view.
    Call oBaseViewOptions.Add("SheetMetalFoldedModel", True)

    ' Open the sheet metal document invisibly
    Dim oModel As Document
    Set oModel = ThisApplication.Documents.Open("Path of file\Mounting Bracket.ipt", False)

    ' Create the placement point object.
    Dim oPoint As Point2d
    Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25)

    ' Create a base view.
    Dim oBaseView As DrawingView
    Set oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1, _
    kDefaultViewOrientation, kHiddenLineRemovedDrawingViewStyle, _
    , , oBaseViewOptions)
    
End Sub

In the above code, path of file need to update after downloading attached part.

 

SheetMetalFoldedModel_FalseSheetMetalFoldedModel_FalseSheetMetalFoldedModel_TrueSheetMetalFoldedModel_True

Please feel free to contact if there is any queries.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



o.sassen
Participant
Participant

Yes it's is working, but I don't understand why. What dit you change? The only difference is the true or false statement. But when I change this in my code it's not working. 

 

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @o.sassen,

 

Can you please share your code to test?

 

please make sure that files and data are non confidential one.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

o.sassen
Participant
Participant

This is what I tried: 

Public Sub AddFlatPatternDrawingView()

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the active sheet.
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet

' Create a new NameValueMap obja jject
Dim oBaseViewOptions As NameValueMap
Set oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

' Set the options to use when creating the base view.
Call oBaseViewOptions.Add("SheetMetalFoldedModel", False)

 

Run-time error '5':

"Invallid procedure call or argument"

' Open the sheet metal document invisibly
Dim oModel As Document
Set oModel = ThisApplication.Documents.Open("C:\Vault\Designs\Klimaat\Projecten\Norby\CO2 Collector\part1.ipt", False)

' Create the placement point object.
Dim oPoint As Point2d
Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(6, 20)

' Create a base view.
Dim oBaseView As DrawingView
Set oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1 / 25, kIsoTopRightViewOrientation, kShadedDrawingViewStyle, _
, , oBaseViewOptions)

' Set oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1 / 25, _
' kFlatBacksidePivotLeftViewOrientation, kHiddenLineRemovedDrawingViewStyle, _
' , , oBaseViewOptions)

End Sub

0 Likes

o.sassen
Participant
Participant

Oh sorry all, I already know what was wrong. I was using a wrong view. 

Case closed. It's is working perfectly now! 

 

0 Likes

dgreatice
Collaborator
Collaborator

Hi,

 

maybe like this?:

 

Public Sub AddFlatPatternDrawingView()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet

    ' Create a new NameValueMap object
    Dim oBaseViewOptions As NameValueMap
    Set oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

    ' Set the options to use when creating the base view.
    Call oBaseViewOptions.Add("SheetMetalFoldedModel", False)

    ' Open the sheet metal document invisibly
    Dim oModel As Document
    Set oModel = ThisApplication.Documents.Open("C:\temp\SheetMetal.ipt", False)

    ' Create the placement point object.
    Dim oPoint As Point2d
    Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25)

    ' Create a base view.
    Dim oBaseView As DrawingView
    Set oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1, _
    kDefaultViewOrientation, kHiddenLineRemovedDrawingViewStyle, _
    , , oBaseViewOptions)

 

   Dim oDwgCurve As DrawingCurve

   For Each oDwgCurve In oBaseView.DrawingCurves

         If oDwgCurve.EdgeType = kBendDownEdge Then
            oDwgCurve.Segments.Item(1).Visible = False
        End If

   Next
End Sub

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @o.sassen,

 

 

Nice to hear that your code is also wokring!!!

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes