Author Topic: Strange problem inserting blocks  (Read 1939 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Strange problem inserting blocks
« on: February 05, 2007, 11:49:15 PM »
In a drawing created by AutoCAD 2007, a VBA routine that works perfectly in 2000, 2002, 2004 and 2006, inserts a block with an attribute, but the attribute is not in the location as defined by the insertion point of the attdef when created in 2007. Further adding to the mystery is that if you use VBA in 2000-2006 to insert one of the blocks created in 2007, the attribute comes in at the correct location, BUT if you use the insert command the attribute comes in at the WRONG location. This is only exhibited on blocks created by VBA in 2007, not blocks created by any other version.
Any ideas?

After looking at the drawing, I tried to insert the blocks with VBA and they were all correct ... thinking that someone was playing a trick on me by moving the attributes and claiming the program did it, I tried inserting the blocks using "INSERT" .. and what do you know ... the attributes are in a different place ..

this is the code I used to insert the blocks with VBA

Code: [Select]
Sub InsertEach()
  Dim Block As AcadBlock
  For Each Block In ThisDrawing.Blocks
      If UCase(Left$(Block.Name, 3)) = UCase("Jor") Then
          ThisDrawing.ModelSpace.InsertBlock ThisDrawing.Utility.GetPoint(, "Select Point: "), Block.Name, 1, 1, 1, 0
      End If
  Next Block
End Sub

Please tell me I am not crazy ... run the vba routine above in the drawing and insert each of the blocks, then insert each of them using the insert command.

and this is the drawing ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Strange problem inserting blocks
« Reply #1 on: February 06, 2007, 01:48:40 AM »
I'm looking at 2006 and it is very weird, even though the vba inserts look fine, if you explode them they go bad.

hendie

  • Guest
Re: Strange problem inserting blocks
« Reply #2 on: February 06, 2007, 03:44:56 AM »
Using 2004:
I inserted the blocks via vba, then inserted the blocks via the Insert command.
Both sets of blocks were identical.
However, as Bryco stated, when the blocks are exploded, the attributes fly off somewhere.
Even stranger, when using the Burst command the attributes stayed in the correct place .

Using 2007:
I inserted the blocks via vba, then inserted the blocks via the Insert command.
Attributes were in a different place than in 2004  :-o
(the attribute for the smallest block was way off in space !)
The blocks inserted using the Insert command came in at scale factor of 0.03937008 (reported through the List command) even although a scale factor of 1 was selected in main dialog  :-o :-o
I tried several times just to make sure I hadn't screwed up but always came in at that scale (btw, 0.03937008 = 1/25.4 so is there some kind of metric/imperial shennannigins going on here ?
Specifying a scale of 2 then querying the block reported a scale factor of 0.07874016)
When exploded, the attributes stayed in their (incorrect) place, same with Burst.

I did note that the insertion units specified was "unitless" << this is only available in the 2007 dialog, so I don't know if this is part of the issue.

hendie

  • Guest
Re: Strange problem inserting blocks
« Reply #3 on: February 06, 2007, 04:03:58 AM »
just some more observations.
the 2004 and the 2007 wblock dialogs are identical but the 2004 and the 2007 Block dialogs differ.
However, it seems to be in terminology only. The 2004 "Drag and drop units" has become "Block Unit" in 2007.
There is no change in the code either to create or insert blocks.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Strange problem inserting blocks
« Reply #4 on: February 06, 2007, 07:59:09 AM »
The funny thing about the whole mess is that the blocks were created programmatically 1:1 in VBA in A2k7 ... I am beginning to wonder if the unitless scall thingy has anything to do with it ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hendie

  • Guest
Re: Strange problem inserting blocks
« Reply #5 on: February 06, 2007, 08:05:26 AM »
I thought that too but I can't explain why they are being inserted at a scale of 1/25.4 when a scale of 1.0 is specified in the dialog. All the units settings in the drawing are set at inches.
when they are inserted programatically, the scale is correct, it's inserting them manually which seems to screw them up