.NET

Reply
Contributor
BugWare
Posts: 13
Registered: ‎04-17-2012
Message 1 of 12 (250 Views)
Accepted Solution

VB.net syntax for adding image without frame

250 Views, 11 Replies
05-23-2014 07:41 AM

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)

Micropaleontology
Oil Industry
try this: Application.SetSystemVariable("imageframe", 0)
ADN Support Specialist
Virupaksha.aithal
Posts: 100
Registered: ‎06-15-2011
Message 2 of 12 (222 Views)

Re: VB.net syntax for adding image without frame

05-26-2014 11:16 PM in reply to: BugWare

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.



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

Contributor
BugWare
Posts: 13
Registered: ‎04-17-2012
Message 3 of 12 (210 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 06:50 AM in reply to: Virupaksha.aithal
Thanks very much Virupaksha. That is certainly easy to to do for the end user, but I really need to do this programatically in VB.NET, and not force the end user to do it. Do you know the syntax that I can add to the code shown above in this thread? Thanks again, Mitch
Micropaleontology
Oil Industry
Mentor
conormccartney3897
Posts: 187
Registered: ‎08-18-2010
Message 4 of 12 (202 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 08:43 AM in reply to: BugWare
try this: Application.SetSystemVariable("imageframe", 0)
Contributor
BugWare
Posts: 13
Registered: ‎04-17-2012
Message 5 of 12 (197 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 09:11 AM in reply to: conormccartney3897
When I try Application.SetSystemVariable("imageframe", 0) I get the compile error:

Error 1 'SetSystemVariable' is not a member of 'System.Windows.Forms.Application'.

I feel like we're getting closer, thanks conormccartney3897.
Micropaleontology
Oil Industry
Mentor
conormccartney3897
Posts: 187
Registered: ‎08-18-2010
Message 6 of 12 (195 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 09:13 AM in reply to: BugWare
check your imports up top, look for this, or add if not there: Imports Autodesk.AutoCAD.ApplicationServices
*Expert Elite*
_gile
Posts: 2,104
Registered: ‎04-29-2006
Message 7 of 12 (192 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 09:14 AM in reply to: BugWare

Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("imageframe", 0)

Gilles Chanteau
Contributor
BugWare
Posts: 13
Registered: ‎04-17-2012
Message 8 of 12 (179 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 11:16 AM in reply to: _gile

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!

Micropaleontology
Oil Industry
*Expert Elite*
_gile
Posts: 2,104
Registered: ‎04-29-2006
Message 9 of 12 (159 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 01:32 PM in reply to: BugWare

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)

 

Gilles Chanteau
Mentor
conormccartney3897
Posts: 187
Registered: ‎08-18-2010
Message 10 of 12 (152 Views)

Re: VB.net syntax for adding image without frame

05-27-2014 01:51 PM in reply to: BugWare
hrmm that is odd behavior, but Gilles method makes more sense, use an if statement like so for VB, if its not equal to 0, then switch: If Application.GetSystemVariable("imageframe") <> 0 Then Application.SetSystemVariable("imageframe", 0) End If
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.