[求助]如何去掉图像的边框?
<br/><font size="3"><br/>AutoCAD2007 + Visual C# 2005</font><br/><br/><br/>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br/><br/>AutoCAD 菜单中有“修改”->“对象”->“图像”->“边框”,可以设置图像边框的有无。<br/><br/>命令行中也可以设置:imageframe<br/><br/>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br/><br/>问题是如何在C#中设置,用代码实现,可以用类似VBA中的SendCommand的函数发送CAD系统命令吗?<br/><br/>或者有其他方法?这个好像跟RasterImage、RasterImageDef对象关系不大。。。<br/><br/><br/> RasterVariables.ImageFrame Property回复:(lzh741206)RasterVariables.ImageFrame Prop...
在代码中加了两行代码RasterVariables rV = new RasterVariables();
rV.ImageFrame = FrameSetting.ImageFrameOff;
为什么还是没反应
<p>RasterVariables是保存在字典里的,我记得是这样</p> 老大,可以说细点不?<br/><br/>找了半天也没找到该在哪里设置。。。<br/>
回复:(lzh741206)RasterVariables是保存在字典里的...
老大,可以说细点不?<br/><br/>找了半天也没找到该在哪里设置。。。回复:(lzh741206)[upload=jpg]UploadFile/2010-7/2...
汗!老大太高深了。。我无从下手啊
看这张图上确实RasterVariables在Dictionary中
但我不知道怎么将字典和RasterVariables中的ImageFrame联系起来(现在还不清楚字典、id、块这些概念,原谅我的无知吧)
我的插入栅格图像中的关于字典的代码是这样的,
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.ObjectId imgDictID = RasterImageDef.GetImageDictionary(db);
//Write the dictionary
DBDictionary imgDict;
imgDict = (DBDictionary)t.GetObject(imgDictID, OpenMode.ForWrite);
Autodesk.AutoCAD.DatabaseServices.ObjectId rasterDefID;
String name = RasterImageDef.SuggestName(imgDict, fName);
if (!imgDict.Contains(name))
{
rasterDefID = imgDict.SetAt(name, rasterDef);
}
///////////////////////////////
应该怎么设置RasterVariables的ImageFrame呢?看了imgDict下的各种函数,好像没有跟RasterVariables联系起来的呢?难道是SetAt?它返回的是id啊 <p><font face="Verdana"><a href="http://forums.autodesk.com/t5/NET/How-to-set-Imageframe-variable/m-p/2594971/highlight/true#M16785">http://forums.autodesk.com/t5/NET/How-to-set-Imageframe-variable/m-p/2594971/highlight/true#M16785</a></font></p>
<p>不过,似乎效果也不好</p>
<p>实在不行就发命令吧,严格的讲<font face="Verdana">ImageFrame是系统变量,但试了设置系统变量也不行</font></p>
回复:(lzh741206)http://forums.autodesk.com/t5/N...
public void ImageFrame()
{
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;
using (Transaction t = tm.StartTransaction())
{
DBDictionary dict = tm.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead) as DBDictionary;
RasterVariables rasterVars;
string kImageVars = "ACAD_IMAGE_VARS";
if(dict.Contains(kImageVars))
{
ObjectId rastVarsId = dict.GetAt(kImageVars);
rasterVars = tm.GetObject(rastVarsId,OpenMode.ForWrite) as RasterVariables;
}
else
{
rasterVars = new RasterVariables();
dict.UpgradeOpen();
dict.SetAt(kImageVars,rasterVars);
tm.AddNewlyCreatedDBObject(rasterVars,true);
}
rasterVars.ImageFrame = FrameSetting.ImageFrameOff;
t.Commit();
}
}
这是我修改成的C#的代码,运行之后发现ImageFrame的值确实改了,用自带命令“IMAGEFRAME”也可以看到其值是0,也就是边框关掉了,
但是边框还是在图上显示得好好的!还是不行!
页:
[1]