Author Topic: Inserting a Raster and Scale  (Read 2185 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Inserting a Raster and Scale
« on: November 05, 2007, 06:43:41 PM »

Hi I have my raster image inserting just fine...etc. etc.
I made the scalefactor = 12#
However, it keeps inserting at 18.82

Does anyone know why this may be happening?

Thanks

Mark

Code: [Select]
Dim RastImg As AcadRasterImage
Dim InsertPnt(0 To 2) As Double, Scalefactor As Double, RotAngle As Double
Dim lpt(0 To 2) As Double
Dim rpt(0 To 2) As Double
Dim mdpt(0 To 2) As Double
 
   
InsertPnt(0) = 0#: InsertPnt(1) = 0#: InsertPnt(2) = 0#
Scalefactor = 12   <-------------------   :lol:
RotAngle = 0

On Error GoTo Errorhandler

Set RastImg = ThisDrawing.PaperSpace.AddRaster(Imgpth & Imgname, InsertPnt, Scalefactor, RotAngle)

RastImg.Name = Imgname

Errorhandler:
   If Err.Description = "File access error" Then
    If MsgBox("No files were selected " & vbCrLf & "Would you like to select a file? ", vbYesNo) = vbYes Then
     LocMap
    Else
     Exit Sub
   End If
   End If

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Inserting a Raster and Scale
« Reply #1 on: November 05, 2007, 07:37:19 PM »
When I inserted an image with ActiveX through Lisp I had to change the scale to 1, but it would scale it to 2.0933333 (which is what I wanted).  So maybe you have to change it to 1, and then change it to 12.  Just an idea.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #2 on: November 06, 2007, 09:46:47 AM »

Quote
I had to change the scale to 1, but it would scale it to 2.0933333 (which is what I wanted). 

Hey Tim,
If you inserted it at 1, how did it know to scale to 2.09?

Just as if I change the scale to 1, how will the raster know to scale to 12?

Do I fake it out and say Scalefactor = 1, Scalefactor = 12?

Thanks

Mark




T.Willey

  • Needs a day job
  • Posts: 5218
Re: Inserting a Raster and Scale
« Reply #3 on: November 06, 2007, 12:52:15 PM »
I would fake it out, and set the ScaleFactor = 1, then change it to 12 (assign the value to the raster image twice).  I don't know how it scaled it correctly with how I did it, but I know it did it.  Maybe I should report it, but I'm not sure how or where to.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #4 on: November 06, 2007, 01:07:42 PM »
Yes
I will try that

VBA definetely is not without quirks but at least we can find ways around these things.

Also, have you noticed that when you insert the raster with VBA, it gives it an OAIM name?

So, then you have to address that as well.

Let me give it a shot

Thanks Tim

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #5 on: November 06, 2007, 01:23:19 PM »

Check this out Tim

Scalefactor = 7.65 'inserts the raster at 12 scale

The above works but WTF?

I can't even think of a ratio that would validate this.

My boss was telling me that the inserted scale is effected by the resolution of the raster...

If this is true and my raster is 600 dpi, then there must be some ratio that can be used to obtain the right scale factor in code.

Mark


T.Willey

  • Needs a day job
  • Posts: 5218
Re: Inserting a Raster and Scale
« Reply #6 on: November 06, 2007, 01:38:47 PM »
Yea I saw the weird name thing also.  I changed that one also with the code I did.  I was also trying to find the ratio to use until I tried to change the scale to 1 and see what happened.  I don't understand, but I'm glad you got something to work for you.  You're welcome Mark.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #7 on: November 06, 2007, 03:59:16 PM »

Yep, VBA handles some things really odd but I guess it is the end result that matters

THanks God for forums like this


Mark


CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: Inserting a Raster and Scale
« Reply #8 on: November 06, 2007, 04:53:28 PM »
Here is where I have addressed that

It is a big pain in the butt
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #9 on: November 06, 2007, 06:21:08 PM »

It sure can be

My boss knocked out the same project in 30 minutes in LISP 
I love VBA but if it can be done in LISP in 1/5 the time and does not need to connect with other VBA Enabled programs, then by all means
LISP it is :)

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Inserting a Raster and Scale
« Reply #10 on: November 06, 2007, 07:26:39 PM »

It sure can be

My boss knocked out the same project in 30 minutes in LISP 
I love VBA but if it can be done in LISP in 1/5 the time and does not need to connect with other VBA Enabled programs, then by all means
LISP it is :)
Don't know if you say my lisp, but here it is.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Bryco

  • Water Moccasin
  • Posts: 1850
Re: Inserting a Raster and Scale
« Reply #11 on: November 06, 2007, 11:19:56 PM »
Every image I insert at scale 12 ends up with a width of 12",
so the misleading scale is really referring to the width.

Set R = ThisDrawing.ModelSpace.AddRaster(p, Zero, 1, 0)
R.ScaleFactor = 12 
 the ScaleFactor works for me though maybe not for Ml
« Last Edit: November 06, 2007, 11:43:30 PM by Bryco »

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #12 on: November 07, 2007, 10:09:56 AM »

Hey Bry

Code: [Select]
Set R = ThisDrawing.ModelSpace.AddRaster(p, Zero, 1, 0)
R.ScaleFactor = 12
Bry, I think p is the name of your raster?
Zero is 0,0? And you are inserting at a scale of 1.
Quote
the ScaleFactor works for me though maybe not for Ml
So, you have tried to insert at a 12 scale and it worked fine?
After inserting did you list the object and it returned a 12 for scale?
Do you have any recommendations?

Also, we had a discussion in this post about how The inserted Raster (via vba) gets an unique name on OAIM*****
When I saw that I said, WTF!
I resolved it with code:
RastImg.Name = Imgname 'imgname = The picked file name

However, my boss brough up a great point and it is the same with Xrefs;
If you insert them manually it will pick up the file name but you do not have to keep the filename as the xref name.
Why you would change it is a bit beyond me but it is possible.
Well the same principle applies with raster images evidentally.

If I say:

RastImg.Name = "Bryco"

Then sure enough my inserted raster will be name Bryco.

Mark

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #13 on: November 07, 2007, 10:34:59 AM »

Hi Guys

I am getting an error: Can't assign to array
Can somebody please tell me where Iam going wrong?
Thank you,
Mark

Code: [Select]
Dim llpnt(0 To 2) As Double
Dim urpnt(0 To 2) As Double
Dim mdpnt(0 To 2) As Double

mdpnt(0) = llpnt(0) + ((urpnt(0) - llpnt(0)) / 2) 'Midpoint (X) = The point in the far left direction - the point in the far right direction / 2
mdpnt(1) = llpnt(1) + ((urpnt(1) - llpnt(1)) / 2) 'Midpoint (Y) = The point in the far top direction - the point in the far bottom direction / 2
mdpnt(2) = 0

Bryco

  • Water Moccasin
  • Posts: 1850
Re: Inserting a Raster and Scale
« Reply #14 on: November 07, 2007, 12:13:20 PM »
I was trying to point out that .ScaleFactor works and the scale field in .AddRaster refers to the width. (different thangs completely)

Can't assign to array- some items require a variant rather than an array of doubles.
dim Pt
Pt=midpnt
yada yada

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #15 on: November 07, 2007, 12:24:12 PM »
Code: [Select]
[code]Yes, I think you are right Bry
I think it is the point that you are picking with the getpoint method that requires a Variant type

Then I think you would create another variable as Double

Ex:
Dim llpnt as Variant 'Pick Lower Left Point
Dim urpnt as Variant 'Pick Upper Right Point
Dim Mdpnt (0 to 2) as Double

llpnt (0) = Mdpnt (0): llpnt (1) = Mdpnt (1): llpnt (2) = Mdpnt (2)
urpnt (0) = Mdpnt (0): urpnt (1) = Mdpnt (1): urpnt (2) = Mdpnt (2)

mdpnt(0) = llpnt(0) + ((urpnt(0) - llpnt(0)) / 2) 'Midpoint (X) = The point in the far left direction - the point in the far right direction / 2
mdpnt(1) = llpnt(1) + ((urpnt(1) - llpnt(1)) / 2) 'Midpoint (Y) = The point in the far top direction - the point in the far bottom direction / 2
mdpnt(2) = 0
[/code]

Is this more like it Bry?

Thanks
Mark


ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #16 on: November 07, 2007, 12:26:19 PM »

Yes, I think you are right Bry
I think it is the point that you are picking with the getpoint method that requires a Variant type

Then I think you would create another variable as Double

Ex:
Code: [Select]
Dim llpnt as Variant 'Pick Lower Left Point
Dim urpnt as Variant 'Pick Upper Right Point
Dim Mdpnt (0 to 2) as Double

llpnt (0) = Mdpnt (0): llpnt (1) = Mdpnt (1): llpnt (2) = Mdpnt (2)
urpnt (0) = Mdpnt (0): urpnt (1) = Mdpnt (1): urpnt (2) = Mdpnt (2)

mdpnt(0) = llpnt(0) + ((urpnt(0) - llpnt(0)) / 2) 'Midpoint (X) = The point in the far left direction - the point in the far right direction / 2
mdpnt(1) = llpnt(1) + ((urpnt(1) - llpnt(1)) / 2) 'Midpoint (Y) = The point in the far top direction - the point in the far bottom direction / 2
mdpnt(2) = 0

Is this more like it Bry?

AHHHHHHHHHHHHH Confusing!!    :-(

Thanks
Mark

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #17 on: November 07, 2007, 12:27:44 PM »

Bry

As to the raster and scale:

Even though I use
Scalefactor = 12

When I list the raster in ACAD, it says scale 18.82

So, while I understand what you are saying, I don't understand what you are saying :)

Is there a different method that I am missing?

Mark

Bryco

  • Water Moccasin
  • Posts: 1850
Re: Inserting a Raster and Scale
« Reply #18 on: November 07, 2007, 07:41:37 PM »
Please post an image.

ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #19 on: November 08, 2007, 02:08:29 PM »

Hi Bry
I am not sure I am doing this right but here it goes

Thank you

Mark


ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #20 on: November 08, 2007, 02:09:55 PM »

OK
Let me try again

Mark


ML

  • Guest
Re: Inserting a Raster and Scale
« Reply #21 on: November 08, 2007, 02:10:41 PM »

OK, I am not getting something right   :-(