明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 690|回复: 0

在VB中遇到的问题

[复制链接]
发表于 2015-6-27 14:46:47 | 显示全部楼层 |阅读模式
我在网上找到了一个关于VB调用CAD图库的问题,然后源码打开后,显示装配有问题。现把源码附上,打开图的时候出现问题。请各位大神看看是什么问题。谢谢啦。每次打开是总是出现“对象变量或with块变量未设置”

  1. '各带总图装配
  2. Private Sub Command6_Click()
  3. copy_move.yc_1.Text = yaolucanshu.yc_1.Text
  4. copy_move.yc_2.Text = yaolucanshu.yc_2.Text
  5. copy_move.yc_3.Text = yaolucanshu.yc_3.Text
  6. copy_move.sc_1.Text = yaolucanshu.sc_1.Text
  7. copy_move.sc_2.Text = yaolucanshu.sc_2.Text
  8. copy_move.lc_1.Text = yaolucanshu.lc_1.Text
  9. copy_move.lc_2.Text = yaolucanshu.lc_2.Text
  10. copy_move.lc_3.Text = yaolucanshu.lc_3.Text
  11. copy_move.mjyc.Caption = Val(yaolucanshu_1.mjc.Text) + Val(yaolucanshu_1.jlc.Text)
  12. Dim yqc As Double, yzc As Double, sqc As Double, jlc As Double, hlc As Double
  13.     yqc = 232 * Val(yaolucanshu.yc_1.Text)
  14.     yzc = 232 * Val(yaolucanshu.yc_2.Text)
  15.     sqc = 232 * Val(yaolucanshu.sc_1.Text)
  16.     jlc = 232 * Val(yaolucanshu.lc_1.Text)
  17.     hlc = 232 * Val(yaolucanshu.lc_2.Text)
  18. Dim objCurDoc As AcadDocument
  19. Dim objNewDoc As AcadDocument
  20. Dim objLastDoc As AcadDocument
  21. Select Case True
  22. Case Option1(0).Value
  23.    AutoCAD_Appliaction
  24. ' 打开第一张图
  25.     Set objCurDoc = acadapp.Documents.Open(App.Path & "\Gallery\预热带前段.dwg")
  26.     copy_moveSset "NEW1", 232, Val(copy_move.yc_1.Text), "0"
  27. ' 打开一个新图形
  28.     Set objNewDoc = acadapp.Documents.Open(App.Path & "\Gallery\预热带中段.dwg")
  29.     copy_moveSset "NEW1", 232, Val(copy_move.yc_2.Text), "0"
  30.     moveSset "NEW1", yqc
  31. '打开最后一个图形
  32.     Set objLastDoc = acadapp.Documents.Open(App.Path & "\Gallery\预热带后段.dwg")
  33.     copy_moveSset "NEW1", 232, Val(copy_move.yc_3.Text), "0"
  34.     moveSset "NEW1", yzc + yqc
  35.    Set objNewDoc = acadapp.ActiveDocument
  36. ' 将外部图形的实体复制到当前图形
  37.    Set ssetobj = CreateSelectionSet
  38.    ssetobj.Select acSelectionSetAll
  39.   acadapp.ActiveDocument.CopyObjects ssArray(ssetobj), objCurDoc.ModelSpace
  40.   objCurDoc.Regen acAllViewports
  41. ' 关闭打开的图形
  42.   objNewDoc.Close (False)
  43.    Set objLastDoc = acadapp.ActiveDocument
  44.    Set ssetobj = CreateSelectionSet
  45.    ssetobj.Select acSelectionSetAll
  46.    acadapp.ActiveDocument.CopyObjects ssArray(ssetobj), objCurDoc.ModelSpace
  47.    objCurDoc.Regen acAllViewports
  48.    objLastDoc.Close (False)

  49. Case Option1(1).Value
  50.       AutoCAD_Appliaction
  51. ' 打开第一张图
  52.     Set objCurDoc = acadapp.Documents.Open(App.Path & "\Gallery\烧成带前段.dwg")
  53.     copy_moveSset "NEW1", 232, Val(copy_move.sc_1.Text), "0"
  54. ' 打开一个新图形
  55.     Set objNewDoc = acadapp.Documents.Open(App.Path & "\Gallery\烧成带保温段.dwg")
  56.     copy_moveSset "NEW1", 183, Val(copy_move.sc_2.Text), "0"
  57.     moveSset "NEW1", sqc

  58.    Set objNewDoc = acadapp.ActiveDocument
  59. ' 将外部图形的实体复制到当前图形
  60.    Set ssetobj = CreateSelectionSet
  61.    ssetobj.Select acSelectionSetAll
  62.   acadapp.ActiveDocument.CopyObjects ssArray(ssetobj), objCurDoc.ModelSpace
  63.   objCurDoc.Regen acAllViewports
  64. ' 关闭打开的图形
  65.   objNewDoc.Close (False)
  66.   
  67. Case Option1(2).Value
  68.   AutoCAD_Appliaction
  69. ' 打开第一张图
  70.     Set objCurDoc = acadapp.Documents.Open(App.Path & "\Gallery\急冷段.dwg")
  71.     copy_moveSset "NEW1", 232, Val(copy_move.lc_1.Text) - 1, "0"
  72. ' 打开一个新图形
  73.     Set objNewDoc = acadapp.Documents.Open(App.Path & "\Gallery\缓冷段.dwg")
  74.     copy_moveSset "NEW1", 232, Val(copy_move.lc_2.Text), "0"
  75.     moveSset "NEW1", jlc
  76. '打开最后一个图形
  77.     Set objNewDoc = acadapp.Documents.Open(App.Path & "\Gallery\快冷段.dwg")
  78.     copy_moveSset "NEW1", 232, Val(copy_move.lc_3.Text), "0"
  79.     moveSset "NEW1", jlc + hlc
  80.    Set objNewDoc = acadapp.ActiveDocument
  81. ' 将外部图形的实体复制到当前图形
  82.    Set ssetobj = CreateSelectionSet
  83.    ssetobj.Select acSelectionSetAll
  84.   acadapp.ActiveDocument.CopyObjects ssArray(ssetobj), objCurDoc.ModelSpace
  85.   objCurDoc.Regen acAllViewports
  86. ' 关闭打开的图形
  87.    objNewDoc.Close (False)
  88.    Set objLastDoc = acadapp.ActiveDocument
  89.    Set ssetobj = CreateSelectionSet
  90.    ssetobj.Select acSelectionSetAll
  91.    acadapp.ActiveDocument.CopyObjects ssArray(ssetobj), objCurDoc.ModelSpace
  92.    objCurDoc.Regen acAllViewports
  93.    objLastDoc.Close (False)
  94. End Select
  95. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 11:50 , Processed in 0.171575 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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