摘要:
相信很多SolidWorks设计师都会遇到这样一个问题,就是SolidWorks工程图出图的时候,我们的SolidWorks焊件切割清单的总重,是没法设置调用的,不能通过单重x数量...
相信很多SolidWorks设计师都会遇到这样一个问题,就是SolidWorks工程图出图的时候,我们的SolidWorks焊件切割清单的总重,是没法设置调用的,不能通过单重x数量实现,但是我们的SolidWorks装配体的材料明细表可以。那么如何实现SolidWorks焊件切割清单的总重呢?今天给大家整理分享一份网络比较认可的方法,大家可以亲自实践。
SolidWorks焊件切割清单总重设置方法
SolidWorks焊件切割清单生成单重和总重的原理呢就是利用“宏”命令来实现,下面就给大家分享这个宏以及使用方法。
宏代码:
Option Explicit Dim swApp As SldWorks.SldWorks Dim Part As SldWorks.ModelDoc2 Dim thisFeat As SldWorks.Feature Dim thisSubFeat As SldWorks.Feature Dim cutFolder As Object Dim BodyCount As Integer Dim fn As String Dim pn As String Dim custPropMgr As SldWorks.CustomPropertyManager Dim propNames As Variant Dim vName As Variant Dim propName As String Dim Value As String Dim resolvedValue As String Dim TotalW As Double Sub main() Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc Set thisFeat = Part.FirstFeature Do While Not thisFeat Is Nothing If thisFeat.GetTypeName = "SolidBodyFolder" Then thisFeat.GetSpecificFeature2.UpdateCutList End If Set thisSubFeat = thisFeat.GetFirstSubFeature Do While Not thisSubFeat Is Nothing If thisSubFeat.GetTypeName = "CutListFolder" Then Set cutFolder = thisSubFeat.GetSpecificFeature2 End If If Not cutFolder Is Nothing Then BodyCount = cutFolder.GetBodyCount If BodyCount > 0 Then Set custPropMgr = thisSubFeat.CustomPropertyManager If Not custPropMgr Is Nothing Then custPropMgr.Delete "Total Weight" custPropMgr.Delete "Weight" fn = thisSubFeat.Name pn = Part.GetTitle custPropMgr.Add "Weight", "文字", Chr(34) & "SW-Mass@@@" & fn & "@" & pn & Chr(34) propNames = custPropMgr.GetNames If Not IsEmpty(propNames) Then For Each vName In propNames propName = vName custPropMgr.Get2 propName, Value, resolvedValue If propName = "Weight" Then TotalW = resolvedValue Next vName End If custPropMgr.Add "Total Weight", "文字", Format(BodyCount * TotalW, "0.00") End If End If End If Set thisSubFeat = thisSubFeat.GetNextSubFeature Loop Set thisFeat = thisFeat.GetNextFeature Loop End Sub
1、打开SolidWorks焊件三维图,编辑切割清单,默认是这种情况,会生成“材料”和“数量”2个属性
2、点击工具-宏-新建
3、将上面的宏代码复制进来,运行宏后添加单重和总重属性
4、然后我们会发现,之前的切割清单多了两项单重和总重(简单的英文大家应该都认识)
5、下面在SolidWorks工程图切割清单里面调用单重和总重
这个英文标题,在切割清单上双击可以修改为单重和总重汉字。
以上就是SolidWorks切割清单总重利用宏命令的方法实现总重的调用,赶紧试一下吧!
发表评论