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: 

flatpattern drawing

10 REPLIES 10
Reply
Message 1 of 11
DWhiteley
559 Views, 10 Replies

flatpattern drawing

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

 

10 REPLIES 10
Message 2 of 11
adam.nagy
in reply to: DWhiteley

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
Message 3 of 11
o.sassen
in reply to: DWhiteley

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! 

 

Message 4 of 11
MechMachineMan
in reply to: o.sassen

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
Message 5 of 11
chandra.shekar.g
in reply to: o.sassen

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



Message 6 of 11
o.sassen
in reply to: chandra.shekar.g

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. 

 

Message 7 of 11
chandra.shekar.g
in reply to: o.sassen

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



Message 8 of 11
o.sassen
in reply to: chandra.shekar.g

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

Message 9 of 11
o.sassen
in reply to: o.sassen

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

Case closed. It's is working perfectly now! 

 

Message 10 of 11
dgreatice
in reply to: DWhiteley

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
Message 11 of 11
chandra.shekar.g
in reply to: o.sassen

Hi @o.sassen,

 

 

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

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



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

Post to forums  

Autodesk Design & Make Report