+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2010
    Posts
    19

    Default How do i get block reference from dwg?

    Registered forum members do not see this ad.

    Ok, so i have created a dymanic block with tags named "ID_EL" and saved it in a dwg named "ID_EL_DWG.dwg".
    I open a new drawing and with vba in want to: import the "ID_EL" reference form the "ID_EL_DWG.dwg" file, and the insert the block 3 times in the modelspace with different tag values.
    I figured out almost everything except the first part.
    How can i load a block reference form another dwg into the current one?

    I don't want to insert the dwg as block because then i must explode it to get acces to my dynamic block with tags to modify it.

    Hope it's not a lot to ask, but i searched the web many times for this and found nothing. (except inserting dwg as block)

    Alternative solutions are also welcome.
    Thanks in advance!
    Last edited by BUrBaKy; 29th Apr 2011 at 09:17 am. Reason: i ate a letter :) (spelling mistake)

  2. #2
    Luminous Being dbroada's Avatar
    Computer Details
    dbroada's Computer Details
    Operating System:
    XP Pro
    Computer:
    Dell
    CPU:
    Intel Xeon 2.13GHz
    RAM:
    2GB
    Graphics:
    NVIDA Quadro FX 580
    Monitor:
    DELL 23" & SAMSUNG 21"
    Discipline
    Electro/Mech
    dbroada's Discipline Details
    Occupation
    Design Engineer
    Discipline
    Electro/Mech
    Using
    Electrical 2013
    Join Date
    Nov 2005
    Location
    Sussex, UK
    Posts
    5,059

    Default

    this was discussed recently and I think the end result was that you couldn't. You can WBLOCK your block out from the drawing it currently lives in to make it available for INSERT without having to explode it. Alternatively you can add a * to the front of your block name to insert it already exploded.
    "That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson

    Dave

  3. #3
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    :: Once you've WBLOCKed your dynamic block ::

    Instead of invoking the Add Method upon the Blocks Collection to define the Block Reference, only to insert said Block Reference (read create a new Block Item) multiple times into the ModelSpace object, why not simply use the InsertBlock Method and do both in one step (repeated x3 times in this situation):

    Code:
     
    object.InsertBlock(InsertionPoint, Name, Xscale, Yscale, ZScale, Rotation [, Password])
    ... Then modify each instance's tags accordingly.

    Hope this helps!
    "Potential has a shelf life." - Margaret Atwood

  4. #4
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2010
    Posts
    19

    Smile I think i got it

    I think i found a way. It's not very professional but it get's the job done.
    Code:
        Dim ipt(0 To 2) As Double
        Dim B As AcadBlockReference
        ipt(0) = 0: ipt(1) = 0: ipt(2) = 0
        Set B = ThisDrawing.ModelSpace.InsertBlock(ipt, "I:\ID_EL_DWG.dwg", 1#, 1#, 1#, 0)
        B.Delete
        Set B = ThisDrawing.ModelSpace.InsertBlock(ipt, "ID_EL", 1#, 1#, 1#, 0)
        ZoomAll
    The thing is that by inserting the dwg, comes also the block reference inside the dwg separately.
    So after the first .InsertBlock i wil have two references: ID_EL_DWG (wich i just inserted) and ID_EL (the block reference in the drawing i just inserted).
    Then i can just erase the dwg and reinsert my wanted block, being assignet to the "B" object, making it ready to be tag-edited

  5. #5
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Quote Originally Posted by BUrBaKy View Post
    Ok, so i have created a dymanic block with tags named "ID_EL" and saved it in a dwg named "ID_EL_DWG.dwg".
    I open a new drawing and with vba in want to: import the "ID_EL" reference form the "ID_EL_DWG.dwg" file, and the insert the block 3 times in the modelspace with different tag values.
    ...
    I don't want to insert the dwg as block because then i must explode it to get acces to my dynamic block with tags to modify it.
    Quote Originally Posted by dbroada View Post
    You can WBLOCK your block out from the drawing it currently lives in to make it available for INSERT without having to explode it.
    Quote Originally Posted by RenderMan View Post
    :: Once you've WBLOCKed your dynamic block ::
    Quote Originally Posted by BUrBaKy View Post
    The thing is that by inserting the dwg, comes also the block reference inside the dwg separately.
    So after the first .InsertBlock i wil have two references: ID_EL_DWG (wich i just inserted) and ID_EL (the block reference in the drawing i just inserted).
    Then i can just erase the dwg and reinsert my wanted block, being assignet to the "B" object, making it ready to be tag-edited
    Huh!? I guess it is true... you can only lead a horse to water.
    "Potential has a shelf life." - Margaret Atwood

  6. #6
    Luminous Being dbroada's Avatar
    Computer Details
    dbroada's Computer Details
    Operating System:
    XP Pro
    Computer:
    Dell
    CPU:
    Intel Xeon 2.13GHz
    RAM:
    2GB
    Graphics:
    NVIDA Quadro FX 580
    Monitor:
    DELL 23" & SAMSUNG 21"
    Discipline
    Electro/Mech
    dbroada's Discipline Details
    Occupation
    Design Engineer
    Discipline
    Electro/Mech
    Using
    Electrical 2013
    Join Date
    Nov 2005
    Location
    Sussex, UK
    Posts
    5,059

    Default

    I must admit to not having read his request too carefully else I would have pointed out you don't need to explode it to get the extra block definitions but even so I thought you led him nicely.

    Somebody used to have a sig about leading horses to water and Sat Navs but I have forgotten what it was.
    "That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson

    Dave

  7. #7
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Quote Originally Posted by dbroada View Post
    I must admit to not having read his request too carefully else I would have pointed out you don't need to explode it to get the extra block definitions but even so I thought you led him nicely.
    No worries; and thank you, that's very kind of you to say.

    Happy Friday.
    "Potential has a shelf life." - Margaret Atwood

  8. #8
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2010
    Posts
    19

    Default My bad

    I tend to think i'm better than horses despite my begginer level in VBA, thank you.

    It's true though, that i said i want to insert in a new file, although i actualy needed it to be inserted in an already open one. The reason i did that is, that i didn't know that it would be a difference (didn't know about the wblock method).
    That's why i couldn't use "wblock" command.
    As for InsertBlock method, it's what i used or maybe i didn't know how to exploit it fully for this case.Living is learning.
    As for the horse, what may be true by lamplight is not always true in sunlight but i have to say you got good diplomatic skills.

  9. #9
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Quote Originally Posted by RenderMan View Post
    Huh!? I guess it is true... you can only lead a horse to water.
    Quote Originally Posted by BUrBaKy View Post
    I tend to think i'm better than horses despite my begginer level in VBA, thank you.
    My statement was analogous to the fact that you were provided a solution (twice), and then completely disregard said solution... I've not actually compared you (or anyone else) to a horse, dude.

    It still is not clear, and truly does not matter, whether you've even tested the proposed solution. I voluntarily made my post and will continue to do so (God willing) for many years to come. What you decide to do with the information I share is, well, exactly that - for you to decide. I'm certainly not always correct.

    Quote Originally Posted by BUrBaKy View Post
    It's true though, that i said i want to insert in a new file, although i actualy needed it to be inserted in an already open one. The reason i did that is, that i didn't know that it would be a difference (didn't know about the wblock method).
    That's why i couldn't use "wblock" command.
    As for InsertBlock method, it's what i used or maybe i didn't know how to exploit it fully for this case.Living is learning.
    We all start somewhere.

    WBLOCK is a command that would remove your need to copy / extract / etc. the Block Reference from another drawing (hence the suggestions). Simply open "ID_EL_DWG.dwg" and enter the WBLOCK command. In the resultant dialog, select 'block' in the upper left, and select "ID_EL" from the drop down list, specify a file path, and desired units, and hit OK.

    The result is a block ("ID_EL.dwg" perhaps?) that can be inserted without duplicate block references ("ID_EL_DWG" and "ID_EL"), instead only making available a single block reference ("ID_EL").

    In which case object.InsertBlock accomplishes your stated goal; simply be sure to include the code necessary to conditionally modify the values for each attribute / property needed.

    Quote Originally Posted by BUrBaKy View Post
    As for the horse, what may be true by lamplight is not always true in sunlight but i have to say you got good diplomatic skills.
    "There are two ways of spreading light; to be the candle, or the mirror that reflects it" - Edith Wharton

    Besides, lamp / flash / chem / cigarette light violates 'light discipline' during night operations; and day or night, if it breathes, there's a scope that can see it:



    (^^ Rifle with day / night vision scope ^^)

    :airborne:
    "Potential has a shelf life." - Margaret Atwood

  10. #10
    Super Member SEANT's Avatar
    Using
    AutoCAD 2012
    Join Date
    Aug 2005
    Location
    Rhode Island
    Posts
    1,968

    Default

    Registered forum members do not see this ad.

    I, too, prefer a block library setup based on a WBLOCK methodology (i.e., one block per drawing) due to the ease of automation. If the “master file” method needed to be preserved, though, this thread shows an additional programming option regarding the transfer of a Block Definitions to a working drawing.

    Inserting the actual reference may require further enhancements to account for dynamic manipulation and/or attributes.
    http://www.cadtutor.net/forum/showthread.php?26666

Similar Threads

  1. Block Reference ID
    By kykuit in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 5
    Last Post: 5th Aug 2010, 04:24 am
  2. Block reference
    By Zorg in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 8th Jun 2009, 10:02 am
  3. Reference Block
    By frankie78 in forum AutoCAD General
    Replies: 2
    Last Post: 27th Mar 2009, 10:19 am
  4. Block reference
    By Attila The Gel in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 24th Feb 2009, 10:58 am
  5. Getting Attributes for one block reference w/many block inserts?
    By muck in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 17th Oct 2006, 03:38 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts