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: 

Bend Tags to view (Add Tags to View)

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
WHassan
562 Views, 3 Replies

Bend Tags to view (Add Tags to View)

Hi,

 

I have a macro to create drawings for all sheet-metal parts in an assembly.

Each drawing has a single view of the flat pattern and a bend table for the same view i.e.

 

 

'Create the view

objDrawingView = objDrawingSheet.DrawingViews.AddBaseView(objMyPartDocument, objMyPoint2D, dblMyViewScale, _ ViewOrientationTypeEnum.kFlatPivotLeftViewOrientation, _ DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, , , objMyNameSpace)

 

 

 

'Create the bend table

objBendTable = objDrawingSheet.CustomTables.AddBendTable(oMyPartDocument.FullFileName, objMy2ndPoint2D, _ "Bend Table", strBendTableColumns, True, "BEND - ")

 

' where strBendTableColumns = {"BEND ID", "BEND DIRECTION", "BEND ANGLE"}

 

 

Now I want to add tags for the bends to the unfolded view of my part. Doing this manually is by right-clicking on the bend table and selecting the option "Add Tags to View" and then clicking on the view (of the flat pattern) But can I get some help to do this through the same macro??

 

Thanking you,

 

Wajih

3 REPLIES 3
Message 2 of 4
WHassan
in reply to: WHassan

I got the following response from the Autodesk support team, so I thought I should post it here for reference; Dear Syed Wajih Hassan, Apologies for our late response. We have backlog in the queue. For some reasons, the original forum link is not available now. I investigated your question. It looks there is not an API for the ability, but the following workaround is working. Could you give it a try whether it helps? Public Sub CreateBendTable() ' Set a reference to the active drawing document Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument ' Set a reference to the active sheet Dim oActiveSheet As Sheet Set oActiveSheet = oDrawDoc.ActiveSheet ' Create the placement point for the table Dim oPoint As Point2d Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25) ' Specify the columns - this can be specified in any combination/order Dim strColumns(1 To 5) As String strColumns(1) = "BEND ID" strColumns(2) = "BEND RADIUS" strColumns(3) = "BEND ANGLE" strColumns(4) = "BEND KFACTOR" strColumns(5) = "BEND DIRECTION" ' Create the bend table by specifying the source sheet metal file Dim oBendTable As CustomTable Set oBendTable = oActiveSheet.CustomTables.AddBendTable("C:\temp\Part1.ipt", oPoint, "Bend Table", strColumns) oDrawDoc.SelectSet.Clear 'select the bend table for executing the command [Add Tag to View] oDrawDoc.SelectSet.Select oBendTable 'oDrawDoc.SelectSet.Select oDrawDoc.ActiveSheet.DrawingViews(1) 'select the drawingview to mimic the user selecting the view ThisApplication.CommandManager.ControlDefinitions("DrawingTableSelectBendViewCtxCmd").Execute End Sub Best Regards, Xiaodong Liang Developer Technical Services http://adn.autodesk.com
Message 3 of 4
WHassan
in reply to: WHassan

Dear Syed Wajih Hassan, Apologies for our late response. We have backlog in the queue. For some reasons, the original forum link is not available now. I investigated your question. It looks there is not an API for the ability, but the following workaround is working. Could you give it a try whether it helps? Public Sub CreateBendTable() ' Set a reference to the active drawing document Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument ' Set a reference to the active sheet Dim oActiveSheet As Sheet Set oActiveSheet = oDrawDoc.ActiveSheet ' Create the placement point for the table Dim oPoint As Point2d Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25) ' Specify the columns - this can be specified in any combination/order Dim strColumns(1 To 5) As String strColumns(1) = "BEND ID" strColumns(2) = "BEND RADIUS" strColumns(3) = "BEND ANGLE" strColumns(4) = "BEND KFACTOR" strColumns(5) = "BEND DIRECTION" ' Create the bend table by specifying the source sheet metal file Dim oBendTable As CustomTable Set oBendTable = oActiveSheet.CustomTables.AddBendTable("C:\temp\Part1.ipt", oPoint, "Bend Table", strColumns) oDrawDoc.SelectSet.Clear 'select the bend table for executing the command [Add Tag to View] oDrawDoc.SelectSet.Select oBendTable 'oDrawDoc.SelectSet.Select oDrawDoc.ActiveSheet.DrawingViews(1) 'select the drawingview to mimic the user selecting the view ThisApplication.CommandManager.ControlDefinitions("DrawingTableSelectBendViewCtxCmd").Execute End Sub Best Regards, Xiaodong Liang Developer Technical Services http://adn.autodesk.com
Message 4 of 4
joe
Contributor
in reply to: WHassan

 

I was trying to do the same, and this post saved me hours.

 

FYI (and in a tidier format), the important bits of code are:

 

oDrawingDocument.SelectSet.Clear()

 

oDrawingDocument.SelectSet.Select(oBendTable)

 

 

oDrawingDocument.SelectSet.Select(oView1)

 

m_inventorApplication.CommandManager.ControlDefinitions("DrawingTableSelectBendViewCtxCmd").Execute()

 

where oBendTable is a custom table (bend table)

oView1 is the drawing view

m_inventorApplication is the running application

 

It might be a bit messy but it works

 

Thank you

 

Joe

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

Post to forums  

Autodesk Design & Make Report