TheSwamp
Code Red => VB(A) => Topic started by: Bryco on June 20, 2006, 02:09:17 PM
-
Having 2006 gives some nice options for setting the insert scaling. But we have both 2004 and 2006 so I need a way to be able to insert our standard reference bubbles etc into both inches and metric not using IAcadBlock3 properties.
I thought the following would work, by scaling the entities in a block if the drawing was metric but
Function isMM() As Boolean
If ThisDrawing.GetVariable("Insunits") = 4 Then
isMM = True
End If
End Function
Function mmBlock(oBlock As AcadBlock)
If isMM Then
Dim Ent As AcadEntity
Dim Ins
Ins = oBlock.Origin
For Each Ent In oBlock
Ent.ScaleEntity Ins, 25.4
Next
oBlock.units = acInsertUnitsMillimeters
End If
End Function
Alas 2006 decides to insert a block at 25.4 scale so the effects are doubled.
Any help appreciated.
-
Just typed on the fly here so some tweaking is going to be needed fo sho but
Function is2k6() As Boolean
If Left(thisdrawing.getvariable("ACADVER"),4) = "16.2" then
is2k6 = true
End if
end function
-
Thanks Bob I use the same thing.
Sometimes knowing what version doesnt stop the error
if is2k6 then
dim B as IAcadBlock3
end if
this throws an error in 2004
-
I see your problem. You might have to run two different versions of the app.
-
What about
Function mmBlock(oBlock As AcadBlock)
If isMM Then
Dim Ent As AcadEntity
Dim Ins
Ins = oBlock.Origin
If not is2k6 then
For Each Ent In oBlock
Ent.ScaleEntity Ins, 25.4
Next
End If
oBlock.units = acInsertUnitsMillimeters
End If
End Function
-
So far that is a very good call Bob.
-
Even a blind dog finds the radish sometimes.
-
Setting the units to inches and inserting the ref at a scale of 1 ends up with a ref scale 0.0394.
So inserting by vba with inch units in a metric dwg you need to use a scale of 25.4
whereas using sendcommand the scale is 1.
I've gone for below, not really knowing if there will be some long term ramifications.
Always Scale theents in the blocks for metric dwgs.
Function mmBlock(oBlock As AcadBlock)
If isMM Then
If AcadVer > 2004 Then
oBlock.units = acInsertUnitsMillimeters
End If
Dim Ent As AcadEntity
Dim ins
ins = oBlock.Origin
For Each Ent In oBlock
Ent.ScaleEntity ins, 25.4
Next
End If
End Function
-
Do not know if it matters to you, but I have been using this number: 3.93700787401575E-02
Sorry I could not be of more help with the other problems. I still do not check the ACAD version. I am just reading your guy's stuff and hoping to learn what to do.
-
Dave 3.93700787401575E-02 is the same as 1/25.4
Does it matter?
My tests show 7.777x7.777 is faster than 7.777^2 and 7.777X0.5 is faster 7.777/2.
However scaling (at the command line) in cad wont allow 1/2.4 but does allow 10/254 which is easy to remember, so I'm used to using that now.
-
Setting the units to inches and inserting the ref at a scale of 1 ends up with a ref scale 0.0394.
I was reading that line and was thinking you were using that value. My bad.
What I learned from your response = my good.
Thanks. I am going to remember those tests of yours.
I am not really sure if it does matter for speed. I am usually only concerned with it working, with the hope that some day some poor programmer will fix it all for me, for payment of course. I never stopped and tried to add the fraction in VB. In theory, it should produce the same result. The time difference, unless noticeable, is a last concern.
My point was that using 0.0394 to scale with, vs. .039370078740157 may produce slightly different result. I am having to split hairs all the time, scaling from metric to imperial and back and so I went with the largest number I could find. I just misunderstood what you were saying. You are not using the value 0.0394, correct? It appears to me that your fraction may actually be a tad slower, but would probably produce the most accurate result, if one is more accurate to the other through VB.
PS. I am still trying to digest that stuff of yours on the first page of the swamp.