几何尺寸与公差论坛

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

【转帖】simply creating a view11 solved

[复制链接]
发表于 2009-4-13 14:21:06 | 显示全部楼层 |阅读模式
simply creating a view!! solved
update::
turns out the true problem was actually that i had set accessselections up and then never released them using releaseselectionaccess.
ok this is becoming an absolute nightmare! something so simple yet nothing is working;
all i want to do is to create a flat pattern view (or any view for that matter) of the currently active part. simple enough yes?
dim swapp as sldworks.sldworks
dim swdrwdoc as drawingdoc
sub main()
set swapp = application.sldworks
dim modname as string
modname = swapp.activedoc.getpathname
set swdrwdoc = swapp.newdrawing2(10, "", 0, 0, 0)
swdrwdoc.createflatpatternviewfrommodelview3(modname, "", 0, 0, 0, true, false)
end sub
or even using swapp.newdocument....
well, it doesn't work! i am having some seriously strange behavious because it randomly seemed to work before so i carried on working and then it went back to not working at all. i even have macros that create flat pattern dxf sheets from the currently open drawing that work, and some others too, yet for some reason this will not work!
anyone who can do this will get a big pat on the back because this has been winding me up for hours now, something so simple that just will not work.
by the way, even the original sw example code does not work!
option explicit
const templatesize as long = swdwgtemplatea1size
const papersize as long = swdwgpapera1size
const paperwidth as double = 0.841 ' meters
const paperheight as double = 0.594 ' meters
sub main()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swdraw as sldworks.drawingdoc
dim swview as sldworks.view
dim bret as boolean
set swapp = createobject("sldworks.application")
set swmodel = swapp.activedoc
set swdraw = swapp.newdrawing2(templatesize, "", papersize, _
paperwidth, paperheight)
set swview = swdraw.createflatpatternviewfrommodelview3( _
swmodel.getpathname, "", _
paperwidth / 2, paperheight / 2, 0#, true, true)
end sub
luke,
i don't know what is going on, but here is the code that i used. it works just fine for me.
public class form1
dim swapp as sldworks.sldworks
dim swdrwdoc as sldworks.drawingdoc
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
swapp = createobject("sldworks.application")
dim modname as string
modname = swapp.activedoc.getpathname
swdrwdoc = swapp.newdrawing2(10, "", 0, 0, 0)
swdrwdoc.createflatpatternviewfrommodelview3(modname, "", 0, 0, 0, true, false)
end sub
end class
maybe you need to change drawingdoc to sldworks.drawingdoc??
tony szuta
cswa, cswp, cswp-smtl
tony,
nope tried all areas. honestly i have been at it for hours now! lol. i have tried it on 3 computers, on sw 2007 and sw 2008 sp3.1, it has never worked on 2007 using over 12 different methods, and has worked on 2008 probably 70% of the time on and off with no meaningful changes to code.
i presumed the code was fine like i say but i do not know what is going on here! something strange. i will leave it for today and see what the computers decide to do tomorrow.
mmmm...
tell you what, open up a sheet metal part and run this macro, see if it works for you.
dim swapp as sldworks.sldworks
dim swdrwdoc as drawingdoc
sub main()
set swapp = application.sldworks
dim modname as string
modname = swapp.activedoc.getpathname
set swdrwdoc = swapp.newdocument(swapp.getuserpreferencestringvalue(swuserpreferencestringvalue_e.swdefaulttemplatedrawing), 0, 0, 0)
swdrwdoc.createflatpatternviewfrommodelview3 modname, "", 0, 0, 0, true, false
end sub
this works for me on solid 2007
try this
sub main()
dim swapp as object
dim selmgr as object
dim part as object
dim swmodel as modeldoc2
dim spathname as string
set swapp = application.sldworks
set swmodel = swapp.activedoc
set part = swapp.newdocument("c:\documents and settings\all users\application data\solidworks\solidworks 2008\templates\dxf.drwdot", 12, 0.21, 0.297)
set selmgr = part.selectionmanager
part.createflatpatternviewfrommodelview swmodel.getpathname, "default", 0.1226368421053, 0.1093105263158, 0
part.clearselection2 true
work perfict for me everytime. solidworks 2008 3.1
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
edited: 06/17/2008 at 12:31 pm by ben guenther
nope, this code does exactly the same as mine, creates the drawing sheet but creates no view
how far are you on this problem?
well it works fine on sw2009 with no changes to the code, and apparently other people have no problem with this, yet it still doesn't work on my 2007 and 2008 on multiple machines.
have you dowloaded the attached macro and tried it yourself?
i tried it indeed ( changed the references to sldworks 2007 and changed the path of the part so it got my sheetmetal part) and it worked...
hi luke, i tried the macro you posted with a couple of sheetmetal parts, both on sw2007 sp5.0 and sw2008 sp3.1. all tests produced a flat blank drawing view.
regards,
declan.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-22 23:15 , Processed in 0.036315 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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