几何尺寸与公差论坛

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

【转帖】flatpatternexport problem

[复制链接]
发表于 2009-4-12 20:56:38 | 显示全部楼层 |阅读模式
flatpatternexport problem
hello to all,
i'm writing an api with some functions and shortcuts to help productivity in my company.
one of the items in the todo list is a shortcut for the saveas dxf.
right now i've managed to test the exportflatpatternview, but when i try to save with modeldocextension.saveas, i always get the same error... #256.
can anyone help me?
when i read the documentation and the examples in vb, it looks like the partdoc class has a "extension" method, but i can't find it.
thanks for your help.
modeldoc2 has the extension method to get the modeldocextension object. partdoc is really a sub class (don't know if that's a real term) of modeldoc2, so you can call partdoc.extension to get the modeldocextension as well. it just may not show up in intellisense.
mike spens
"automating solidworks using macros"
leap frog leap pad x64
the modeldoc2 is the base class, partdoc is an inherant class (polymorphism class) that derives all the properties and methods of the base modeldoc2 class (including extension property) and adds part specific properties and methods.
in vba casting from a derived class to a base class is automatic so the user is unaware of this happening, but if you needed to see the intellisense you would do the following:
dim mod as modeldoc2
mod = mypartdocobject
mod.extension
where mypartdocobject is a partdoc variable.
originally posted by: luke malpass
the modeldoc2 is the base class, partdoc is an inherant class (polymorphism class) that derives all the properties and methods of the base modeldoc2 class (including extension property) and adds part specific properties and methods.
in vba casting from a derived class to a base class is automatic so the user is unaware of this happening, but if you needed to see the intellisense you would do the following:
dim mod as modeldoc2
mod = mypartdocobject
mod.extension
where mypartdocobject is a partdoc variable.
thanks for the sugestion, i'll try that first thing in the morning.
meanwhile, please take a look at my actual code, maybe you can find anything wrong.
edited: 11/16/2008 at 06:45 pm by rui santos
if i do the following:
sldworks.sldworks swapp;
modeldoc2 document;
string finalname;
bool disposed;
swapp = new sldworks.sldworks();
document = (modeldoc2)swapp.activedoc;
finalname = "c:\\myfile.dxf";
saveas(document, "dxf");
the code works fine and saves the myfile.dxf file to the c:\ drive. i presume your problem is the finalname string, what does the value equal when you are calling the save function?
finalname is only a concatenation of paths, filename and the extension.
for the test i'm doing, the final result is \\\\ceilocalstorage\\desenhos\\dxf\\testequinagem.dxf
your previous sugestion didn't work  i keep receiving the error 256.
can you explain more about the saveas sintax you used int your test? i see that you only put in two arguments, but the method needs more. thanks
best regards,
rui santos
edited: 11/17/2008 at 06:00 am by rui santos
the following works fine:
place this anywhere you like, such as on a button click event:
sldworks.sldworks swapp;
modeldoc2 document;
string finalname;
bool disposed;
swapp = new sldworks.sldworks();
document = (modeldoc2)swapp.activedoc;
finalname = "c:\\myfile.dxf";
saveas(document, "dxf");
and that calls the function you defined here, which all works:
private bool saveas(modeldoc2 document, string extension)
{
if (document == null) throw new argumentnullexception("document");
if (extension == null) throw new argumentnullexception("extension");
if (disposed) throw new objectdisposedexception("object already disposed");
modeldocextension documentex = document.extension;
switch (extension)
{
case "dxf":
{
try
{
setdxfsettings();
partdoc part = (partdoc) document;
int errors = 0;
int warnings = 0;
modelview mdv = (modelview) document.activeview;
mdv.framestate = (int)swwindowstate_e.swwindowmaximized;
if (part.exportflatpatternview(finalname, 0))
{
if (!documentex.saveas(finalname, 0, 0, null, ref errors, ref warnings))
{
myuseraddin.myerrorhandler.adderror(
string.format("ficheiro {0} não guardado. erro: {1}; warning: {2}.",
finalname, (swfilesaveerror_e) errors,
(swfilesavewarning_e) warnings), document.getpathname());
return false;
}
else
{
myuseraddin.myerrorhandler.adderror(
string.format("ficheiro {0} não permite planificação", extension),
document.getpathname());
return false;
}
}
}
catch (exception e)
{
console.writeline(e);
}
break;
}
}
return true;
}
ah, ok. i didn't understand your idea at first.
is it possible that i have to update the references to the exported dll's from solidworks?
because even if i hardcode the finalname to "c:\\myfile.dxf", the error is the same.
i'm going crazy, here!
try to re-add references. if you still struggle just email me your c# project files and i will fix it for you (contact@angelsix.com)
i've tried that, luke.
now i'm totally lost!!! i jus found out that the code is saving the file, even though is sending this error. can this be?
if so, why is it sending out the error? aren't error codes suposed to be used for debugging?
well, i'll keep with my work. thanks for the help, i really appreciate it.
do you know where should i post this issue? i think we are looking into some kind of bug...
best regards,
rui santos
i have had many bugs with error reporting from things such as setting custom properties, where if you alter a configuration specific property the error value is inverted (so 1 is good, 0 is bad) compared to a custom property where 1 is bad and 0 is good for example, so more than likely it may be a bug. however, saying that batchprocess doesn't recieve faulty error codes for any of its saveas functions and it is intensively used and tested by many companies and platforms so i would say it is more than likely a localised issue.
if you wish to gain further help email apisupport@solidworks.com they will test it out for you to see if they can reproduce the error.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 05:49 , Processed in 0.037106 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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