当前位置:   article > 正文

solidworks批量图号分离_SolidWorks图号名称分离宏.docx

solidworks批量图号名称分离宏

SolidWorks宏代码,用来分离文件名中的图号与零件名并自动写入属性,文件名不需要“-”或者空格等特殊符号,不限制图号长度,均可识别并分离使用方法打开宏工具栏2 点击新建宏按钮 选择路径,输入新建宏名称3删除窗口里的所有代码,把本文档里的代码粘贴进去保存4打开SolidWorks自定义5 打开命令标签,选择宏,把方框里的图标拖动到SolidWorks主界面工具栏6 在弹出窗口浏览刚刚保存的宏文件路径,点击确定7 在打开文件的情况下,点击刚刚在工具栏创建的宏按钮即可自动识别并写入属性以下为代码:Sub MAIN()Set swApp = CreateObject("sldworks.application")Set Part = swApp.ActiveDocswApp.ActiveDoc.ActiveView.FrameState = 1Set CurCFG = Part.GetActiveConfiguration()ConfName = CurCFG.NameName = swApp.ActiveDoc.GetTitle() c = Replace(Name, " ", "")blnretval = Part.AddCustomInfo3(ConfName, "代号", swCustomInfoText, frmPartID)blnretval = Part.AddCustomInfo3(ConfName, "名称", swCustomInfoText, frmPartID)blnretval = Part.AddCustomInfo3(ConfName, "备注", swCustomInfoText, frmPartID) b = Len(c) e = Right(c, 7)If e = ".SLDPRT" Or e = ".SLDASM" Or e = ".sldprt" Or e = ".sldasm" Then g = Left(c, b - 7)Else g = cEnd If l = Len(g) h = Left(g, 2) k = Len(g)For I = 1 To Len(g) If Asc(Mid$(g, I, 1)) < 0 Then w = I Exit For End IfNextFor I = 0 To Len(g) - 1 If Asc(Mid$(g, Len(g) - I, 1)) < 0 Then X = Len(g) - I Exit For End IfNextIf w > 0 Then If w = 1 Then s = Left(g, X) t = Right(g, k - X) Else t = Left(g, w - 1) s = Right(g, k - w + 1) End IfElse s = "" t = gEnd Ifdummy = Part.Extension.CustomPropertyManager(Part.ConfigurationManager.ActiveConfiguration.Name).Set("代号", t)dummy = Part.Extension.CustomPropertyManager(Part.ConfigurationManager.ActiveConfiguration.Name).Set("名称", s)dummy = Part.Extension.CustomPropertyManager(Part.ConfigurationManager.ActiveConfiguration.Name).Set("备注", j)End Sub

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/771828
推荐阅读
相关标签
  

闽ICP备14008679号