几何尺寸与公差论坛

 找回密码
 注册
查看: 1043|回复: 0

【转帖】looking for help debugging hatch macro please

[复制链接]
发表于 2009-4-12 21:34:39 | 显示全部楼层 |阅读模式
looking for help debugging hatch macro please
it errors out on this line and the next just like it.
set myhatch = part.sketchmanager.createboundaryhatch(0, 1, 0, "solid", "")
here's the entire macro...pretty simple and it is used to fill in a clients title block for security before it goes out of engineering.
thanks in advance !
----------
dim swapp as object
dim part as object
dim boolstatus as boolean
dim longstatus as long, longwarnings as long
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
dim mymodelview as object
set mymodelview = part.activeview
mymodelview.framestate = swwindowstate_e.swwindowmaximized
part.clearselection2 true
dim sksegment as object
set sksegment = part.sketchmanager.createline(0.484769, 0.010429, 0#, 0.484769, 0.071389, 0#)
set sksegment = part.sketchmanager.createline(0.484769, 0.071389, 0#, 0.598904, 0.071389, 0#)
set sksegment = part.sketchmanager.createline(0.598904, 0.071389, 0#, 0.598904, 0.010429, 0#)
set sksegment = part.sketchmanager.createline(0.598904, 0.010429, 0#, 0.484769, 0.010429, 0#)
part.clearselection2 true
set sksegment = part.sketchmanager.createline(0.695017, 0.050434, 0#, 0.695017, 0.071389, 0#)
set sksegment = part.sketchmanager.createline(0.695017, 0.071389, 0#, 0.851481, 0.071389, 0#)
set sksegment = part.sketchmanager.createline(0.851481, 0.071389, 0#, 0.851481, 0.050434, 0#)
set sksegment = part.sketchmanager.createline(0.851481, 0.050434, 0#, 0.695017, 0.050434, 0#)
part.clearselection2 true
part.setpickmode
boolstatus = part.extension.selectbyid2("line65", "sketchsegment", 0.4869114016407, 0.05152816862172, 0, true, 0, nothing, 0)
boolstatus = part.extension.selectbyid2("line66", "sketchsegment", 0.4978219188474, 0.07062157373335, 0, true, 0, nothing, 0)
boolstatus = part.extension.selectbyid2("line67", "sketchsegment", 0.5987442030088, 0.04516370025118, 0, true, 0, nothing, 0)
boolstatus = part.extension.selectbyid2("line68", "sketchsegment", 0.5687402806905, 0.01197754374765, 0, true, 0, nothing, 0)
dim myhatch as object
set myhatch = part.sketchmanager.createboundaryhatch(0, 1, 0, "solid", "")
boolstatus = part.extension.selectbyid2("line69", "sketchsegment", 0.6960296481013, 0.0642571053628, 0, true, 0, nothing, 0)
boolstatus = part.extension.selectbyid2("line70", "sketchsegment", 0.7046671408899, 0.06971236396613, 0, true, 0, nothing, 0)
boolstatus = part.extension.selectbyid2("line71", "sketchsegment", 0.8501407036452, 0.06562092001364, 0, true, 0, nothing, 0)
boolstatus = part.extension.selectbyid2("line72", "sketchsegment", 0.8424124206238, 0.04970974908728, 0, true, 0, nothing, 0)
set myhatch = part.sketchmanager.createboundaryhatch(0, 1, 0, "solid", "")
end sub
option explicit
sub main()
dim swapp as sldworks.sldworks
dim part as sldworks.partdoc
dim boolstatus as boolean
dim sksegment(7) as sldworks.sketchsegment
dim myhatch as variant
dim i as integer
set swapp = application.sldworks
set part = swapp.activedoc
boolstatus = part.extension.selectbyid2("front plane", "plane", 0, 0, 0, false, 0, nothing, 0)
part.sketchmanager.insertsketch true
part.clearselection2 true
set sksegment(0) = part.sketchmanager.createline(0.484769, 0.010429, 0#, 0.484769, 0.071389, 0#)
set sksegment(1) = part.sketchmanager.createline(0.484769, 0.071389, 0#, 0.598904, 0.071389, 0#)
set sksegment(2) = part.sketchmanager.createline(0.598904, 0.071389, 0#, 0.598904, 0.010429, 0#)
set sksegment(3) = part.sketchmanager.createline(0.598904, 0.010429, 0#, 0.484769, 0.010429, 0#)
set sksegment(4) = part.sketchmanager.createline(0.695017, 0.050434, 0#, 0.695017, 0.071389, 0#)
set sksegment(5) = part.sketchmanager.createline(0.695017, 0.071389, 0#, 0.851481, 0.071389, 0#)
set sksegment(6) = part.sketchmanager.createline(0.851481, 0.071389, 0#, 0.851481, 0.050434, 0#)
set sksegment(7) = part.sketchmanager.createline(0.851481, 0.050434, 0#, 0.695017, 0.050434, 0#)
part.clearselection2 true
for i = 0 to 3
sksegment(i).select true
next i
myhatch = part.sketchmanager.createboundaryhatch(0, 1, 0, "solid", "")
for i = 4 to 7
sksegment(i).select true
next i
myhatch = part.sketchmanager.createboundaryhatch(0, 1, 0, "solid", "")
part.sketchmanager.insertsketch true
end sub
edited: 03/24/2009 at 06:40 pm by ivana kolin
thank you .... much cleaner. very nice
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2025-1-11 10:25 , Processed in 0.038969 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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