![]() |
【转帖】split body feature in vb.ne
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 |
所有的时间均为北京时间。 现在的时间是 06:48 AM. |