SolidWorks机械工程师网——最大的SolidWorks学习平台

 找回密码
 立即注册

QQ登录

只需一步,快速开始

好品数字
好品数字
查看: 3693|回复: 22
打印 上一主题 下一主题

Solidworks拼图打印程序(源码公布)

  [复制链接]

6

主题

246

帖子

24

金币

侠客

Rank: 3Rank: 3Rank: 3

积分
285
QQ
楼主
发表于 2013-12-16 22:34:45 | 显示全部楼层
    Imports System.Drawing
    Imports System.Drawing.Graphics
    Module PictureRelated
        Sub joinPicture()
            '每一张大图
            Dim mm As Integer = 1
            For Each ds As ptPaper In FinalPapers
                '图片大小
                newBMape = New Bitmap(CInt(841 * intDPI / 25.4), CInt(594 * intDPI / 25.4))
                '设置分辨率
                newBMape.SetResolution(intDPI, intDPI)
                g1 = Graphics.FromImage(newBMape)
                g1.Clear(Color.White)
                For Each sdraw As SwDraw In ds.inNerPapers
                    myImage = Image.FromFile(sdraw.drawDir)
                   
                    If sdraw.PaperSize = "A2" Then
                        myImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
                        '如果是A2,则宽高翻转,同时将图像进行90度翻转
                        theHeight = CInt(sdraw.drawWidth * intDPI / 25.4)
                        theWidth = CInt(sdraw.drawHeight * intDPI / 25.4)
                      
                    Else
                        theHeight = CInt(sdraw.drawHeight * intDPI / 25.4)
                        theWidth = CInt(sdraw.drawWidth * intDPI / 25.4)
                      
                    End If
                    If sdraw.PaperSize = "A4" Then
                        theX = CInt(sdraw.insertPosX * intDPI * 210 / 25.4)
                        theY = CInt(sdraw.insertPosY * intDPI * 297 / 25.4)
                    End If
                    If sdraw.PaperSize = "A3" Then
                        theX = CInt(sdraw.insertPosX * intDPI * 210 / 25.4)
                        theY = CInt(sdraw.insertPosY * intDPI * 297 / 25.4)
                    End If
                    If sdraw.PaperSize = "A2" Then
                        theX = CInt(sdraw.insertPosX * intDPI * 210 / 25.4)
                        theY = CInt(sdraw.insertPosY * intDPI * 297 / 25.4)
                    End If
                   
                    g1.DrawImage(myImage, theX, theY)
                    myImage.Dispose()
                Next
                If Form1.CBoxPaperSize.SelectedIndex = 1 Then
                    newBMape.RotateFlip(RotateFlipType.Rotate90FlipNone)
                End If
                If Form1.CBoxPrint.Checked = True Then
                    printThepaper()
                End If
                If Form1.CBoxPicSave.Checked = True Then
                    newBMape.Save(Application.StartupPath + "outputimagexx" + mm.ToString + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
                End If
                mm += 1
                g1.Dispose()
                newBMape.Dispose()
            Next
            
        End Sub
    End Module

复制代码
SolidWorks机械工程师网
提示:建议使用谷歌浏览器浏览本网站!如单击这里下载!否则,可能无法下载附件文件!(支持大多数版本的谷歌浏览器,支持360和QQ浏览器的极速模式,即谷歌内核模式,使用IE和Edge浏览器,浏览个别网页以及下载文件时,会误报“***不安全”,此时需要单击“继续访问此不安全站点(不推荐)”才可以继续下载,另外,本网站不含任何不安全的文件,已联系微软公司解决,纯属IE和Edge浏览器误报)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭 卷起
关闭 卷起

手机版|小黑屋| GMT+8, 2024-5-16 16:35 , Processed in 0.155399 second(s), 32 queries .

SolidWorks机械工程师网 ( 鲁ICP备14025122号-2 ) 鲁公网安备 37028502190335号

声明:本网言论纯属发表者个人意见,与本网立场无关。
如涉版权,可发邮件: admin@swbbsc.com

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