My VB.NET app uses the code below to insert a JPG image into the drawing. What is the syntax for making it NOT add the frame around the image? Thanks in advance. Mitch
'Insert Picture
Dim insertionPoint(2) As Double
Dim scalefactor As Double
Dim rotAngleInDegree, rotAngle As Double
Dim imageName As String
Dim raster As Autodesk.AutoCAD.Interop.Common.AcadRasterImage
Dim startPoint(2) As Double
imageName = "C:\TestImage.jpg"
insertionPoint(0) = 1.0
insertionPoint(1) = Tier1BoxHt 'TopEdge - 0.4 'Tier1BoxHt + Tier2BoxHt + Tier3BoxHt / 2 '0.1 '6.1
scalefactor = 1.0#
rotAngleInDegree = 0.0#
rotAngle = rotAngleInDegree * 3.141592 / 180.0#
raster = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotAngle)
Solved! Go to Solution.
Solved by conormccartney3897. Go to Solution.
Hi,
Drawing of frame around the image is controlled by system variable “IMAGEFRAME”. You need to set system variable IMAGEFRAME to 0 to avoid drawing of frame around the image. Refer AutoCAD help for different values IMAGEFRAME takes.
Both solutions by conormccartne3897 and _gile work nicely... sort of. Odd behavior... I've tested this over and over, and it's always the same.
This code does set imageframe to 0. However, if you exit AutoCAD, it remembers that setting, but the next time you run this code it doesn't work. You can see that imageframe is set to 0 on the command line. So if you manually change imageframe to 1, then exit the program, rerun it, the code works again.
So... imageframe has to be already set to 1 for this code to work. If it's set to 0 to start with, the codewon't work and the image will have a frame.
I just realized while writing this that the simple solution to the problem is to set the imageframe to 1 first, then set it to 0. An extra line of code, but that does the trick.
Thanks very much!
BugWare a écrit :
I just realized while writing this that the simple solution to the problem is to set the imageframe to 1 first, then set it to 0. An extra line of code, but that does the trick.
Don't make unusefull work, just check the current value.
Not certain of VB syntax
Imports AcApp = Autodesk.AutoCAD.ApplicationSevices.Application ... If CShort(AcApp.GetSystemVariable("IMAGEFRAME") = 1 Then AcApp.SetSystemVariable("IMAGEFRAME", 0)
I just happen to be working on a method that requires this, and it is based on the code here: http://adndevblog.typepad.com/autocad/2012/05/access-raster-image-variables-using-the-net-api.html (VB.NET)
Or in the case it is useful, the counter part in C#, that works for me here:
var nodDictionary = transaction.GetObject(database.NamedObjectsDictionaryId, OpenMode.ForRead) as DBDictionary;
if (nodDictionary != null)
{
conststring acadImageVars = "ACAD_IMAGE_VARS";
RasterVariables rasterVariables;
if (nodDictionary.Contains(acadImageVars))
{
var acadImageVarsId = nodDictionary.GetAt(acadImageVars);
rasterVariables = transaction.GetObject(acadImageVarsId, OpenMode.ForWrite) as RasterVariables;
}
else
{
rasterVariables = new RasterVariables();
nodDictionary.UpgradeOpen();
nodDictionary.SetAt(acadImageVars, rasterVariables);
transaction.AddNewlyCreatedDBObject(rasterVariables, true);
}
if (rasterVariables != null)
{
rasterVariables.ImageFrame = FrameSetting.ImageFrameOff;
}
}
HTH.
But it IS already equal to 0 when the program starts, so checking to see if it's 0 won't help. It must be changed to 1, then set back to 0 to get it to work. I've tested this several times.