Blocks with a * in front

Discussion in 'AutoCAD' started by Nygaard-Rasch, Aug 10, 2004.

  1. I have some blocks with a * in the front of the name (*U14)

    How can I change the name with VBA

    Thanks

    Carsten
     
    Nygaard-Rasch, Aug 10, 2004
    #1
  2. You shouldn't or else you stand to loose any internal interaction with
    those blocks. For example, *U?? represent hatch patterns and if you rename
    them, the hatch patterns will loose their associativity. Same goes for *D??
    which are dimensions. If you are building some sort of app and don't want
    to see them, just filter your app to ignore any blocks that start with an
    asterisk [*]

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Aug 10, 2004
    #2
  3. Nygaard-Rasch

    antmjr Guest

    In my (hobbyist) experience it's impossible.
    *Ublocks are anonymous, i.e. not referenced;
    the *U_code is assigned automatically by AutoCAD every time you enter the drawing; so *U243 may became *U987 next time; apparently it's not possible to write *Ublock on hard disk too : the Wblock dialog box prevents you from choosing anonymous blocks. You ought to write a sub that reads the *Ublock subentities (lisp language, sorry) and draws them again, building a new *referenced* block with the name you want
     
    antmjr, Aug 10, 2004
    #3
  4. Nygaard-Rasch

    antmjr Guest

    since I'm on holiday, I took a look to sutphin's book (sorry for my benigni-like language; besides, I don't like benigni)
    ---
    I'd suggest the following:
    a) explode the *U block via .explode method, which returns a variant array of a *copy* of all the entities of the original *Ublock
    aa) delete the original *Ublock if you like
    b) create a new empty referenced block with the name you like
    c) populate your new_referenced_block with the .CopyObjects method, which expects a variant array (!) of entities
     
    antmjr, Aug 10, 2004
    #4
  5. Thanks for your help.


    benigni-like language; besides, I don't like benigni)of a *copy* of all the entities of the original *Ublock
    expects a variant array (!) of entities
     
    Nygaard-Rasch, Aug 12, 2004
    #5
  6. Nygaard-Rasch

    antmjr Guest

    hi!
    I tried your problem the other day, just out of curiosity;
    (maybe you have already solved it);
    this sub makes a new block
    from the original [scaled][rotated][mirrored] blockreference,
    *not* from the original block; then it substitutes
    the old blockreference for the new

    Sub k()
    Dim n As Double
    Dim BkR As AcadBlockReference
    Dim pk As Variant
    Dim lst As Variant
    Dim NewName As String
    Dim NewBk As AcadBlock

    On Error GoTo EXIT1
    ThisDrawing.Utility.GetEntity BkR, pk, vbCrLf & "Pick a BlockReference..."

    'here i look for a blockname not used yet;
    '(it's a rough control, but working)
    Do
    Err.Clear
    n = n + 1
    NewName = "User" & Format(n, "00#")
    'you can easily change the code above to check a generic name, got via dialogbox
    On Error Resume Next
    ThisDrawing.Blocks.Item NewName
    Loop Until Err <> 0

    Err.Clear
    On Error GoTo EXIT1
    pk = BkR.InsertionPoint
    'here I copy the inner objects of the original block
    lst = BkR.Explode

    Set NewBk = ThisDrawing.Blocks.Add(pk, NewName)
    ThisDrawing.CopyObjects lst, NewBk
    If (ThisDrawing.ActiveSpace = acModelSpace) Then
    ThisDrawing.ModelSpace.InsertBlock pk, NewName, 1, 1, 1, 0
    Else
    ThisDrawing.PaperSpace.InsertBlock pk, NewName, 1, 1, 1, 0
    End If

    'eventually i delete the original copied objects and block
    For n = 0 To UBound(lst)
    lst(n).Delete
    Next
    BkR.Delete
    Exit Sub
    EXIT1:
    MsgBox Err.Description
    End Sub
     
    antmjr, Aug 12, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.