solidworks的焊件切割清单不能像bom表那样行列相乘,比如单重X数量=总重,求高人赐教。 5
3个回答
展开全部
单重X数量=总重
这个太容易实现了,就是BOM表中的方程式可以搞定,这个只能计算这个模块的这个零件的信息,如果想要整个机器所有零件的统计,目前好像材料明细表无法做到哦,可以导出到Excel,用VBA自动计算
给你一个比较简单的按装配层级关系的BOM表的分组、计算数量的程序,有兴趣可以自己改改,拿去用
Sub 整理BOM表()
Dim nTotal_Row, sheet_name
Dim Master_PN
Set xlapp = Application
On Error Resume Next
Range("A1").Select
Selection.UnMerge
'去掉网格线显示
If ActiveWindow.DisplayGridlines Then ActiveWindow.DisplayGridlines = False
' 关闭自动计算和自动更新屏幕
If Application.ScreenUpdating Then
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
End If
nTotal_Row = ActiveSheet.UsedRange.Rows.Count
nTotal_Column = ActiveSheet.UsedRange.Columns.Count
''设置组合样式
With ActiveSheet.Outline
.AutomaticStyles = False
.SummaryRow = xlAbove '参数 xlBelow 是+-号在下方
.SummaryColumn = xlLeft '参数 xnTotal_Rowight 是+-号在右方
End With
Selection.ApplyOutlineStyles
Rows.ClearOutline '清除所有现有的分组
For i = 2 To nTotal_Row
j = i
mothertxtlong = Len(Cells(i, 1))
Do
j = j + 1
Son_Front_txt = Left(Cells(j, 1), mothertxtlong)
Mother_txt = Left(Cells(i, 1), mothertxtlong)
Loop Until Son_Front_txt <> Mother_txt Or j > nTotal_Row
If j - i > 1 Then
Rows(i + 1 & ":" & j - 1).Group
For k = i + 1 To j - 1
Cells(k, 7).Formula = "=$G$" & i & "*F" & k
Next
End If
Next
'打开自动计算
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Range("A1").Select
End Sub
这个太容易实现了,就是BOM表中的方程式可以搞定,这个只能计算这个模块的这个零件的信息,如果想要整个机器所有零件的统计,目前好像材料明细表无法做到哦,可以导出到Excel,用VBA自动计算
给你一个比较简单的按装配层级关系的BOM表的分组、计算数量的程序,有兴趣可以自己改改,拿去用
Sub 整理BOM表()
Dim nTotal_Row, sheet_name
Dim Master_PN
Set xlapp = Application
On Error Resume Next
Range("A1").Select
Selection.UnMerge
'去掉网格线显示
If ActiveWindow.DisplayGridlines Then ActiveWindow.DisplayGridlines = False
' 关闭自动计算和自动更新屏幕
If Application.ScreenUpdating Then
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
End If
nTotal_Row = ActiveSheet.UsedRange.Rows.Count
nTotal_Column = ActiveSheet.UsedRange.Columns.Count
''设置组合样式
With ActiveSheet.Outline
.AutomaticStyles = False
.SummaryRow = xlAbove '参数 xlBelow 是+-号在下方
.SummaryColumn = xlLeft '参数 xnTotal_Rowight 是+-号在右方
End With
Selection.ApplyOutlineStyles
Rows.ClearOutline '清除所有现有的分组
For i = 2 To nTotal_Row
j = i
mothertxtlong = Len(Cells(i, 1))
Do
j = j + 1
Son_Front_txt = Left(Cells(j, 1), mothertxtlong)
Mother_txt = Left(Cells(i, 1), mothertxtlong)
Loop Until Son_Front_txt <> Mother_txt Or j > nTotal_Row
If j - i > 1 Then
Rows(i + 1 & ":" & j - 1).Group
For k = i + 1 To j - 1
Cells(k, 7).Formula = "=$G$" & i & "*F" & k
Next
End If
Next
'打开自动计算
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Range("A1").Select
End Sub
展开全部
做个宏,复制如下代码做成宏:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swTable As SldWorks.TableAnnotation
Dim nNumRow As Long
Dim i As Long
Sub main()
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
Set swView = swDraw.GetFirstView
Do While Not swView Is Nothing
Set swTable = swView.GetFirstTableAnnotation
Do While Not swTable Is Nothing
nNumRow = swTable.RowCount '获取切割清单行数
For i = 0 To nNumRow - 2
swTable.Text(i, 6) = "={2}E" & i + 1 & "*F" & i + 1 '写入总重方程式到切割清单E列*F列
Next i
Set swTable = swTable.GetNext
Loop
Set swView = swView.GetNextView
Loop
End Sub
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swTable As SldWorks.TableAnnotation
Dim nNumRow As Long
Dim i As Long
Sub main()
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
Set swView = swDraw.GetFirstView
Do While Not swView Is Nothing
Set swTable = swView.GetFirstTableAnnotation
Do While Not swTable Is Nothing
nNumRow = swTable.RowCount '获取切割清单行数
For i = 0 To nNumRow - 2
swTable.Text(i, 6) = "={2}E" & i + 1 & "*F" & i + 1 '写入总重方程式到切割清单E列*F列
Next i
Set swTable = swTable.GetNext
Loop
Set swView = swView.GetNextView
Loop
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我刚才试了一下使用方程式可以实现,功能和EXCEL一样
追问
不是一个一个的链接哦,我希望他能像bom表直接进行 行列编辑,而不是像用公式编辑单元格那样的哦。那样太麻烦了,都是些重复性劳动。我可以看看你的截图么?要gif的动画
追答
这个就不知道了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询