找回密码 注册 QQ登录
一站式解决方案

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
打印 上一主题 下一主题

[求助] 求助:Solidworks工程图打印的问题

[复制链接]
11
发表于 2016-4-5 16:12:43 | 只看该作者
这个也是实际问题,可惜没看到解决办法
12
发表于 2016-4-5 17:05:12 | 只看该作者
楠柠檬、 发表于 2016-4-2 14:08
工作要细心的,都到了最后一步了,好好看看吧

也只能这样了
13
发表于 2016-4-5 21:46:29 | 只看该作者
不明白有零件图 要展开图做啥,如果是下料 直接导出DXF 文件,不就好了
14
发表于 2016-4-6 22:31:23 | 只看该作者
你必须每次点击当前图纸,其他没有任何办法
15
发表于 2016-4-7 16:08:41 | 只看该作者
本帖最后由 takeshi999 于 2016-4-7 16:13 编辑
  1. Option Explicit

  2. ' Define user type to reduce the number of #If VBA7 statements
  3. ' Can't eliminate them...
  4. Private Type LongPtr_T
  5. #If VBA7 Then
  6.     Value As LongPtr
  7.     ' Compare automatically resized LongPtr to fixed size Long and LongLong
  8. #Else
  9.     Value As Long
  10. #End If
  11. End Type

  12. ' Win32 data type. Different signatures for different versions of VBA
  13. Private Type BROWSEINFO
  14. #If VBA7 Then
  15.     hWndOwner       As LongPtr
  16.     pIDLRoot        As LongPtr
  17.     pszDisplayName  As Long
  18.     lpszTitle       As String
  19.     ulFlags         As Long
  20.     lpfnCallback    As LongPtr
  21.     lParam          As Long
  22.     iImage          As Long
  23. #Else
  24.     hWndOwner As Long
  25.     pIDLRoot        As Long
  26.     pszDisplayName  As Long
  27.     lpszTitle       As String
  28.     ulFlags         As Long
  29.     lpfnCallback    As Long
  30.     lParam          As Long
  31.     iImage          As Long
  32. #End If
  33. End Type

  34. Private Const MAX_PATH = 260
  35. 'Directories only
  36. Private Const BIF_RETURNONLYFSDIRS = &H1&
  37. 'Windows 2000 (Shell32.dll 5.0) extended dialog
  38. Private Const BIF_NEWDIALOGSTYLE = &H40
  39. ' show edit box
  40. Private Const BIF_EDITBOX = &H10&

  41. Private Const WM_USER = &H400
  42. Private Const BFFM_INITIALIZED = 1
  43. Private Const BFFM_SELCHANGED = 2
  44. Private Const BFFM_SETSTATUSTEXTA = (WM_USER + 100)

  45. Private Const BFFM_SETSELECTIONA = (WM_USER + 102)
  46. Private Const BFFM_SETEXPANDED = (WM_USER + 16)

  47. Private m_sDefaultFolder As String

  48. Public Const SWP_NOMOVE = 2
  49. Public Const SWP_NOSIZE = 1
  50. Private Const SWP_NOZORDER = 4

  51. Private Type RECT
  52.     Left As Long
  53.     Top As Long
  54.     Right As Long
  55.     Bottom As Long
  56. End Type

  57. ' Win32 API declarations. Different signatures for different versions of VBA.
  58. ' Note the mandatory use of PtrSafe keyword in VBA7.
  59. #If VBA7 Then
  60. Private Declare PtrSafe Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  61. Private Declare PtrSafe Function SHBrowseForFolder Lib "Shell32" (lpbi As BROWSEINFO) As Long
  62. Private Declare PtrSafe Function SHGetPathFromIDList Lib "Shell32" (ByVal pidList As LongPtr, ByVal lpBuffer As String) As Long
  63. Private Declare PtrSafe Sub CoTaskMemFree Lib "ole32" (ByVal hMem As LongPtr)
  64. Private Declare PtrSafe Function SetWindowPos Lib "USER32" (ByVal hWnd As LongPtr, _
  65.                                        ByVal hWndInsertAfter As LongPtr, _
  66.                                        ByVal x As Long, _
  67.                                        ByVal y As Long, _
  68.                                        ByVal cx As Long, _
  69.                                        ByVal cy As Long, _
  70.                                        ByVal wFlags As Long) As Long
  71. Private Declare PtrSafe Function GetWindowRect Lib "user32.dll" (ByVal hWnd As LongPtr, lpRect As RECT) As Long

  72. #Else
  73. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  74. Private Declare Function SHBrowseForFolder Lib "Shell32" (lpbi As BROWSEINFO) As Long
  75. Private Declare Function SHGetPathFromIDList Lib "Shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
  76. Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal hMem As Long)
  77. Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
  78.                                        ByVal hWndInsertAfter As Long, _
  79.                                        ByVal x As Long, _
  80.                                        ByVal y As Long, _
  81.                                        ByVal cx As Long, _
  82.                                        ByVal cy As Long, _
  83.                                        ByVal wFlags As Long) As Long
  84. Private Declare Function GetWindowRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT) As Long

  85. #End If

  86. Private lastKnownPosition As RECT
  87. Private lockLastKnownPosition As Boolean

  88. Public Function BrowseForFolder() As String
  89.   Dim tBI         As BROWSEINFO
  90.   Dim lngPIDL     As LongPtr_T
  91.   Dim strPath     As String
  92.   
  93.   With tBI
  94.     .lpszTitle = "Select the folder you want to use."

  95.     ' TO DO: Do you want the new UI? Or the initial selected folder visible when the dialog opens?
  96.     ' Choose one of the following:
  97.     '  New UI. Selected folder is probably out of view.
  98.     .ulFlags = BIF_RETURNONLYFSDIRS Or BIF_NEWDIALOGSTYLE Or BIF_EDITBOX
  99.     ' ... or ...
  100.     ' Old UI. Selected folder is scrolled into view when dialog opens.
  101.     '.ulFlags = .ulFlags = BIF_RETURNONLYFSDIRS
  102.     ' ... or ...
  103.     ' Old UI with edit box. Selected folder is scrolled into view when dialog opens.
  104.     ' Focus defaults to the edit box making the selected folder less obvious in the tree.
  105.     '.ulFlags = .ulFlags = BIF_RETURNONLYFSDIRS Or BIF_EDITBOX
  106.    
  107.     .lpfnCallback = GetAddress(AddressOf BrowseCallbackProc).Value
  108.   End With
  109.   
  110.   lockLastKnownPosition = True
  111.   lngPIDL.Value = SHBrowseForFolder(tBI)
  112.   If (lngPIDL.Value <> 0) Then
  113.     ' get path from ID list
  114.     strPath = Space$(MAX_PATH)
  115.     SHGetPathFromIDList lngPIDL.Value, strPath
  116.     strPath = Left$(strPath, InStr(strPath, Chr$(0)) - 1)
  117.     ' release list
  118.     CoTaskMemFree lngPIDL.Value
  119.   End If
  120.   BrowseForFolder = strPath
  121. End Function

  122. ' Callback function for Win32 API.
  123. ' Must conform to the expected method signature therefore cannot use our LongPtr_t
  124. #If VBA7 Then
  125. Private Function BrowseCallbackProc(ByVal hWnd As LongPtr, ByVal uMsg As Long, ByVal lParam As Long, ByVal lpData As Long) As Long
  126. #Else
  127. Private Function BrowseCallbackProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal lParam As Long, ByVal lpData As Long) As Long
  128. #End If
  129.         ' If dialog has been initialised, record its current location
  130.         If Not lockLastKnownPosition Then
  131.             GetWindowRect hWnd, lastKnownPosition
  132.         End If
  133.         
  134.         Select Case uMsg
  135.         Case BFFM_INITIALIZED
  136.             ' Start recording the dialogs location
  137.             lockLastKnownPosition = False
  138.             
  139.             If Len(m_sDefaultFolder) > 0 Then
  140.                 ' Move the dialog to the last recorded position
  141.                 SetWindowPos hWnd, 0, lastKnownPosition.Left, lastKnownPosition.Top, 0, 0, SWP_NOSIZE + SWP_NOZORDER
  142.                 ' Set the selected folder
  143.                 SendMessage hWnd, BFFM_SETSELECTIONA, True, ByVal m_sDefaultFolder
  144.             End If
  145.         Case BFFM_SELCHANGED
  146.             SendMessage hWnd, BFFM_SETEXPANDED, True, ByVal m_sDefaultFolder

  147.         End Select
  148. End Function

  149. ' Workaround for syntax limitation of AddressOf. Can only use in a function call, not an assignment
  150. #If VBA7 Then
  151. Private Function GetAddress(nAddress As LongPtr) As LongPtr_T
  152. #Else
  153. Private Function GetAddress(nAddress As Long) As LongPtr_T
  154. #End If
  155.     Dim address As LongPtr_T
  156.     address.Value = nAddress
  157.     GetAddress = address
  158. End Function
复制代码

16
发表于 2016-4-7 16:34:07 | 只看该作者

不好意思,我没用过宏,所以我把这段代码输进去以后没法运行,请问是怎么回事?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
17
发表于 2016-4-7 16:35:28 | 只看该作者

請問這段代碼的作用是什麼呢?:doubt
18
发表于 2016-4-9 15:47:55 | 只看该作者
估计printout2语名可以用于打印宏吧,实现当前图纸的打印,以下是该语名的帮助说明,把起始页和终止页都设为当前页

Dim instance As IModelDoc
Dim FromPage As Integer
Dim ToPage As Integer
Dim NumCopies As Integer
Dim Collate As Boolean
Dim Printer As String
Dim Scale As Double
Dim PrintToFile As Boolean
Dim PtfName As String

instance.PrintOut2(FromPage, ToPage, NumCopies, Collate, Printer, Scale, PrintToFile, PtfName)
19
发表于 2016-4-10 00:26:48 | 只看该作者
拼一个宏:在多页工程图中直接打印当前图纸

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
20
发表于 2016-4-10 12:18:36 | 只看该作者
谢谢楼上神人。可是代码加密了,声称学习的淫情何以堪。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2025-1-9 23:49 , Processed in 0.026588 second(s), 10 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2025 www.iCAx.org

快速回复 返回顶部 返回列表