+ Reply to Thread
Results 1 to 6 of 6

Thread: Block Inserting

  1. #1
    Full Member
    Using
    AutoCAD 2000
    Join Date
    Jun 2008
    Posts
    47

    Default Block Inserting

    Registered forum members do not see this ad.

    I am trying to insert two different blocks into another block. I have done this many times using the same code but now I am getting an error. I am really lost. The part of my code that is giving me trouble is below. At this point in the code MainBlock has already been set, InsertBlock1 and 2 have been defined and InStng and OutStng are the names of the two blocks that I want to insert. Does anyone have any suggestions?


    Code:
    Dim BlockObj1 As AcadBlockReference
    Dim BlockObj2 As AcadBlockReference
                
    Set BlockObj1 = MainBlock.InsertBlock(InsertBlock1, InStng, 1, 1, 1, 0)
    Set BlockObj2 = MainBlock.InsertBlock(InsertBlock2, OutStng, 1, 1, 1, pi)

  2. #2
    Senior Member borgunit's Avatar
    Using
    Mechanical 2006
    Join Date
    May 2007
    Location
    Ohio USA
    Posts
    287

    Default

    Could we take a peek at the error it returns?
    AutoCAD Mechanical 2006
    XP PRO SP3
    http://mechcad-insider.blogspot.com/

  3. #3
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default

    ND

    Where is the insertion point in your code?
    Do you still have the examples from our last post?

    It looks like you failed to define an insertion point for the blocks to be inserted.

    Also, have you ever used The Locals (for debugging) in VBA?

    ML

  4. #4
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default

    ND,
    Also, what is Mainblock set to?

    Your code needs to look something like this:

    Code:
    Dim BlockObj1 As AcadBlockReference
    Dim Inspnt as Variant
     
    Inspnt = ThisDrawing.Utility.GetPoint(, "Please select the insertion point")
     
    Set BlockObj1 = ThisDrawing.ModelSpace.InsertBlock(Inspnt, "G:\PathToBlock\Blockname.dwg", 1, 1, 1, 0)
    If you don't want the user to pick a point, then try hard coding the coords in:

    Code:
    Dim BlockObj1 As AcadBlockReference
     
    Set BlockObj1 = ThisDrawing.ModelSpace.InsertBlock(100,50,0, "G:\PathToBlock\Blockname.dwg", 1, 1, 1, 0)
    ML

  5. #5
    Full Member
    Using
    AutoCAD 2000
    Join Date
    Jun 2008
    Posts
    47

    Default

    Thanks all. It was a problem with the insertion point. All I had for my declaration was Dim insertblock1(0 to 2). I totally spaced the as double part. I feel smart

  6. #6
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default

    Registered forum members do not see this ad.

    Hey ND
    Glad that helped
    After I looked at your code, I thought that was it.

    Yes, points are a little weird to understand at first.

    Check it out,

    If you are prompting a user to pick a point, then declare it as a variant type.

    Dim pnt as Variant

    If you are going to use the points coords X, Y and Z to do something like move the block, then you do this

    Dim pnts (0 to 2) as Double
    pnts (0) 'this = X
    pnts (1) 'this = Y
    pnts (2) 'this = Z

    Data type double handles large numbers

    If you'd like to see an example, I can post something

    ML

Similar Threads

  1. inserting a w block
    By crumpysmom in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 18th Jun 2008, 02:33 pm
  2. inserting a block
    By rookie37 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 19th May 2008, 05:17 pm
  3. Macro for inserting a block
    By cisrael in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 17th May 2007, 06:09 pm
  4. Getting a block to scale when inserting
    By cadclutze in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 5th Oct 2006, 11:33 pm
  5. Inserting a block
    By comcu in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 13th Jul 2006, 01:33 pm

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