TheSwamp

Code Red => VB(A) => Topic started by: Humbertogo on September 19, 2006, 02:30:11 PM

Title: insertunits
Post by: Humbertogo on September 19, 2006, 02:30:11 PM
Is there  a way to know in what units a block is drawing before insert the as block?

Thanks
Title: Re: insertunits
Post by: David Hall on September 19, 2006, 03:01:40 PM
What is your default?  I'm assuming your wanting to know b/c its someone elses block?
Title: Re: insertunits
Post by: Humbertogo on September 19, 2006, 03:23:20 PM
i use autocad mechanical 2006
and use the AMLIBRARY to insert a block from the library
but we drawing in inches as mm.
for example
I work in a mm drawing and insert a block with the AMLIBRARY
even the insertunits is set to 4 Millimeters the block is insert 1:1
and not scale 25.4

if i use the insert command the block will scale automatic

i can Handel  this with a event

Private Sub AcadDocument_ObjectAdded(ByVal Object As Object)
' On Error GoTo ERR_Clear
Dim objBlock As AcadBlockReference
If TypeOf Object Is AcadBlockReference Then
Set objBlock = Object

'
but not all blocks are drawing in inches some of then are drawing in mm
i need to know in witch units they are drawing to specific the scale
Title: Re: insertunits
Post by: David Hall on September 19, 2006, 03:33:16 PM
wow, that hurts my brain just thinking about it.  I'll look and see if there are any ways to tell what it is drawn too.
Title: Re: insertunits
Post by: Bryco on September 19, 2006, 04:08:37 PM
Units may help you, I'm not sure, perhaps you can insert the blockref
then check the block.units then rescale the block if reqd.
Dim B As IAcadBlock3

Debug.Print B.units
Title: Re: insertunits
Post by: Humbertogo on September 20, 2006, 08:28:31 AM
unfortunately Debug.Print B.units is always 0
Title: Re: insertunits
Post by: Bryco on September 20, 2006, 01:44:08 PM
I should have listened to CmdrDuh-it hurts your brain.
So I've found no way, other than opening the dwg to find the units.
However.
Using a metric dwg and inserting a unitless inches dwg.
Using vba, it seemed like whatever combo of  InsUnits , INSUNITSDEFSOURCE, INSUNITSDEFTARGET I set first,the blockref came in at the 1,1,1 scale I had set

Next trying insert with INSUNITS=0    DEFSOURCE=4   DEFTARGET=4
In the properties window the blockunit says inches unit factor 1 and x is 25.4
 INSUNITS=0    DEFSOURCE=1   DEFTARGET=4   the same
 INSUNITS=0    DEFSOURCE=4   DEFTARGET=1 bad for both  inches x is 1 and mm x is 0.0394

As help says the INSUNITSDEFSOURCE and  INSUNITSDEFTARGET only play when insunits =0
When using 4 for insunits I had good results on unitless drawings.
Interestingly the properties window now says inches unit factor 25.4 and x is 1

I don't know how to set a  drawing from unitless.
Title: Re: insertunits
Post by: Bryco on September 20, 2006, 02:22:03 PM
I'll have another go at this.
The units property reflects the insunits value of the drawing.
A standard inches dwg will have
INSUNITS=1    DEFSOURCE=1   DEFTARGET=1
A standard mm dwg will have
INSUNITS=4    DEFSOURCE=1   DEFTARGET=1 (Cad blunder, 4,4,4 is better)
To create a truely unitless drawing you need
INSUNITS=0    DEFSOURCE=0   DEFTARGET=0
as a mm dwg with the INSUNITS set to 0 will still have
DEFSOURCE=1   DEFTARGET=1 and so will insert like an inch drawing.

So Humbertogo you may need to change all the unitless dwgs to their correct setting.
Unitless blocks are handy for ???? unit circles of 1 unit, confusing people, making refernce blocks.