几何尺寸与公差论坛

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

【转帖】split body feature in vb.ne

[复制链接]
发表于 2009-4-13 14:38:40 | 显示全部楼层 |阅读模式
split body feature in vb.net
i'm working on a project where i need to insert a split body feature and i can't seem to get the postsplitbody method to work. i think it may have something to do with how i'm passing the arguments to the method but i've tried everything i could think of. i get an error "the server threw an exception. (exception from hresult: 0x80010105 (rpc_e_serverfault))" when i run the code below and in my real app i'm getting a memory address error. this code originally came from a macro that works with no problems.
sub main()
dim swapp as sldworks.sldworks
dim model as sldworks.modeldoc2
dim part as sldworks.partdoc
dim selmgr as sldworks.selectionmgr
dim swfeatmgr as sldworks.featuremanager
dim boolstatus as boolean
dim feature as sldworks.feature
dim vresultingbodies as object
dim vbodiestomark as object
dim vbodynames as object
dim vbodyorigins as object
dim bodiestomark(0) as object
dim bodynames(0) as object
dim bodyorigins(0) as object
try
swapp = createobject("sldworks.application")
model = swapp.activedoc
part = model
selmgr = part.selectionmanager
swfeatmgr = part.featuremanager
boolstatus = model.extension.selectbyid2("top plane", "plane", 0.0, 0.0, 0.0, true, 0, nothing, 0)
vresultingbodies = swfeatmgr.presplitbody
part.clearselection2(true)
bodiestomark(0) = vresultingbodies(0)
bodynames(0) = ""
bodyorigins(0) = nothing
vbodiestomark = bodiestomark
vbodynames = bodynames
vbodyorigins = bodyorigins
feature = swfeatmgr.postsplitbody((vbodiestomark), true, (vbodyorigins), (vbodynames))
catch ex as exception
msgbox(ex.message)
end try
answer it appears that the arguments need to handled as dispatchwrappers rather than objects. here is the solution from api support. anyone care to elaborate on the dispatchwrapper class and marshalling in general as i'm not quite up to snuff on the topic.
sub main()
dim swapp as sldworks.sldworks
dim model as sldworks.modeldoc2
dim part as sldworks.partdoc
dim selmgr as sldworks.selectionmgr
dim swfeatmgr as sldworks.featuremanager
dim boolstatus as boolean
dim feature as sldworks.feature
dim vresultingbodies as object
dim bodiestomark(0) as object
dim bodynames(0) as object
dim bodyorigins(0) as object
dim odisbodiestomark() as dispatchwrapper
dim odisbodynames() as dispatchwrapper
dim odisbodyorigins() as dispatchwrapper
dim cutfeature as sldworks.feature
dim splitbodydef as sldworks.splitbodyfeaturedata
try
'swapp = createobject("sldworks.application")
swapp = marshal.getactiveobject("sldworks.application.16")
model = swapp.activedoc
part = model
selmgr = part.selectionmanager
swfeatmgr = part.featuremanager
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-22 18:30 , Processed in 0.035097 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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