TheSwamp
Code Red => VB(A) => Topic started by: ML 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
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
-
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.
-
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
-
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.
-
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
-
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
-
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.
-
Yep, VBA handles some things really odd but I guess it is the end result that matters
THanks God for forums like this
Mark
-
Here is where I have addressed that (http://www.theswamp.org/index.php?topic=9095.0)
It is a big pain in the butt
-
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 :)
-
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. (http://www.theswamp.org/index.php?topic=19772.0)
-
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
-
Hey Bry
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.
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
-
Hi Guys
I am getting an error: Can't assign to array
Can somebody please tell me where Iam going wrong?
Thank you,
Mark
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
-
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
-
[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
-
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
Is this more like it Bry?
AHHHHHHHHHHHHH Confusing!! :-(
Thanks
Mark
-
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
-
Please post an image.
-
Hi Bry
I am not sure I am doing this right but here it goes
Thank you
Mark
(http://FtWashington600.tif)
-
OK
Let me try again
Mark
(http://I:\eng\hrsdemo14\dwg\FtWashington600.tif)
-
OK, I am not getting something right :-(