| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 831 人关注过本帖
标题:{求助} 对象变量或WITH块变量未设置 问题 不会弄
只看楼主 加入收藏
l99468082
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-5-3
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
{求助} 对象变量或WITH块变量未设置 问题 不会弄
本人没学过vb 因为有C的基础 帮同学做参数化设计 都是自己摸索的 最近出现这个问题 一直不懂 希望好心人解答一下 点调试的时候他 提示的是彩虹中间的那句
Option Explici
Private Sub Command1_Click()
Dim swapp As Object
Dim part As Object
Dim boolstatus As Boolean
Set swapp = CreateObject("SldWorks.Application")
Set part = swapp.NewPart()
swapp.Visible = True


boolstatus = part.Extension.SelectByID2("前视基准面", "PLANE", -6.25712882977298E-02, 5.90387960021915E-02, 9.04119314857682E-03, False, 0, Nothing, 0)
part.SketchManager.InsertSketch True
part.ClearSelection2 True
Dim skSegment As Object
Set skSegment = part.SketchManager.CreateLine(0#, Val(Text3.Text) / 1000 + 0.012, 0#, 0#, Val(Text3.Text) / 1000 + 0.003, 0#)
Set skSegment = part.SketchManager.CreateLine(0#, Val(Text3.Text) / 1000 + 0.003, 0#, Val(Text2.Text) / 1000, Val(Text3.Text) / 1000 + 0.003, 0#)
Set skSegment = part.SketchManager.CreateLine(Val(Text2.Text) / 1000, Val(Text3.Text) / 1000 + 0.003, 0#, Val(Text2.Text) / 1000, Val(Text3.Text) / 1000, 0#)
Set skSegment = part.SketchManager.CreateLine(Val(Text2.Text) / 1000, Val(Text3.Text) / 1000, 0#, Val(Text2.Text) / 1000 + Val(Text4.Text) / 1000, Val(Text3.Text) / 1000, 0#)
Set skSegment = part.SketchManager.CreateLine(Val(Text2.Text) / 1000 + Val(Text4.Text) / 1000, Val(Text3.Text) / 1000, 0#, Val(Text2.Text) / 1000 + Val(Text4.Text) / 1000, 0#, 0#)
Set skSegment = part.SketchManager.CreateLine(Val(Text2.Text) / 1000 + Val(Text4.Text) / 1000, 0#, 0#, -(Val(Text4.Text) / 1000 + Val(Text1.Text) / 1000 + 0.012), 0#, 0#)
Set skSegment = part.SketchManager.CreateLine(-(Val(Text4.Text) / 1000 + Val(Text1.Text) / 1000 + 0.012), 0#, 0#, -(Val(Text4.Text) / 1000 + Val(Text1.Text) / 1000 + 0.012), Val(Text3.Text) / 1000, 0#)
Set skSegment = part.SketchManager.CreateLine(-(Val(Text4.Text) / 1000 + Val(Text1.Text) / 1000 + 0.012), Val(Text3.Text) / 1000, 0#, -(Val(Text1.Text) / 1000 + 0.012), Val(Text3.Text) / 1000, 0#)
Set skSegment = part.SketchManager.CreateLine(-(Val(Text1.Text) / 1000 + 0.012), Val(Text3.Text) / 1000, 0#, -(Val(Text1.Text) / 1000 + 0.012), Val(Text3.Text) / 1000 + 0.003, 0#)
Set skSegment = part.SketchManager.CreateLine(-(Val(Text1.Text) / 1000 + 0.012), Val(Text3.Text) / 1000 + 0.003, 0#, -0.012, Val(Text3.Text) / 1000 + 0.003, 0#)
Set skSegment = part.SketchManager.CreateLine(-0.012, Val(Text3.Text) / 1000 + 0.003, 0#, -0.012, Val(Text3.Text) / 1000 + 0.012, 0#)
Set skSegment = part.SketchManager.CreateLine(-0.012, Val(Text3.Text) / 1000 + 0.012, 0#, 0#, Val(Text3.Text) / 1000 + 0.012, 0#)
part.ClearSelection2 True
part.SketchManager.InsertSketch True
part.ShowNamedView2 "*上下二等角轴测", 8
part.SketchManager.InsertSketch True
boolstatus = part.Extension.SelectByID2("Line6", "SKETCHSEGMENT", -1.01957156131803E-02, 7.14884174183693E-03, 1.18324328780167E-02, True, 0, Nothing, 0)
part.ClearSelection2 True
boolstatus = part.Extension.SelectByID2("草图1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = part.Extension.SelectByID2("Line6", "SKETCHSEGMENT", -1.01957156131803E-02, 7.14884174183693E-03, 1.18324328780167E-02, True, 16, Nothing, 0)
Dim myFeature As Object
Set myFeature = part.FeatureManager.FeatureRevolve2(True, True, False, False, False, False, 0, 0, 6.2831853071796, 0, False, False, 0.01, 0.01, 0, 0, 0, True, True, True)
part.SelectionManager.EnableContourSelection = False
boolstatus = part.Extension.SelectByID2("上视基准面", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
Dim myRefPlane As Object
Set myRefPlane = part.FeatureManager.InsertRefPlane(8, Val(Text6.Text) / 1000, 0, 0, 0, 0)
part.ClearSelection2 True
part.SketchManager.InsertSketch True
boolstatus = part.Extension.SelectByID2("基准面1", "PLANE", -8.36927347930245E-02, 4.48153637395357E-02, 2.50257290590767E-02, False, 0, Nothing, 0)
Dim mySketchSlot As Object
Dim swSketchSlotCreationType_e As Object
Dim swSketchSlotLengthType_e As Object

Set mySketchSlot = part.SketchManager.CreateSketchSlot(swSketchSlotCreationType_e.swSketchSlotCreationType_center_line, swSketchSlotLengthType_e.swSketchSlotLengthType_CenterCenter, Val(Text5.Text) / 1000, -(1 / 2 * Val(Text1.Text) / 1000 + 0.012), 0, 0, -(0.012 + 0.01 + 1 / 2 * Val(Text5.Text) / 1000), 0, 0, 0, 0, 0, 1, False)

part.ClearSelection2 True
boolstatus = part.Extension.SelectByID2("Point5", "SKETCHPOINT", -4.99133765742045E-02, 0, 0, False, 0, Nothing, 0)
part.SketchAddConstraints "sgFIXED"


Set mySketchSlot = part.SketchManager.CreateSketchSlot(swSketchSlotCreationType_e.swSketchSlotCreationType_center_line, swSketchSlotLengthType_e.swSketchSlotLengthType_CenterCenter, Val(Text5.Text) / 1000, 1 / 2 * Val(Text2.Text) / 1000, 0, 0, Val(Text2.Text) / 1000 - 0.01 - 1 \ 2 * Val(Text5.Text) / 1000, 0, 0, 0, 0, 0, 1, False)




boolstatus = part.Extension.SelectByID2("Point13", "SKETCHPOINT", 2.70281920579684E-02, 0, 0, False, 0, Nothing, 0)
part.SketchAddConstraints "sgFIXED"
part.ClearSelection2 True
part.SketchManager.InsertSketch True
part.SketchManager.InsertSketch True




part.ClearSelection2 True
boolstatus = part.Extension.SelectByID2("草图2", "SKETCH", 0, 0, 0, False, 4, Nothing, 0)
Set myFeature = part.FeatureManager.FeatureCut3(True, False, True, 0, 0, 0.124, 0.01, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, False, True, True, True, True, False, 0, 0, False)
part.SelectionManager.EnableContourSelection = False


End Sub
搜索更多相关主题的帖子: 彩虹 基准面 False 
2015-05-03 14:38
lianyicq
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:26
帖 子:737
专家分:3488
注 册:2013-1-26
收藏
得分:20 
提示的是彩虹中间的那句?
没看到设置了with块,没用solidworks,建议用对象浏览器看看,出错的地方对象是否引用正确,属性和方法是不是对应。

大开眼界
2015-05-04 09:39
快速回复:{求助} 对象变量或WITH块变量未设置 问题 不会弄
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048384 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved