+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Using
    Architecture 2011
    Join Date
    Jul 2011
    Posts
    5

    Default VBA help - block insertion

    Registered forum members do not see this ad.

    Hi There

    Sorry that this will be such a basic question. I am not a VBA expert in any way....quite new actually . Running Autocad Architecure 2014.

    I have a VBA utility that I have made a special button for. I want this button to insert a dynamic block.
    I have WBLOCK'ed the block and it is in a nework folder - no issues here.

    There are several other snippets of VBA code that I have found online (even from this forum) and have tried to modify them to work. I must be doing something wrong, as it always stumbles within the code or silently sits there doing nothing.

    I just want to click this button and my dynamic block (from network) will be brought into the existing drawing, and the user will select insert point and direction..... Mouse click...done....block inserted. Similar action to a block that would be brought from a tool pallette (but has to be from this VBA utility)

    Any help would be appreciated.

    Matt

  2. #2
    Super Member Tyke's Avatar
    Computer Details
    Tyke's Computer Details
    Operating System:
    Windows 7 - 64 bit, W8 + W8.1 Vista
    Computer:
    HP Z400 Workstation
    CPU:
    Intel(R) Xeon(R) CPU W3530 @ 2.80GHz
    RAM:
    8 GB
    Graphics:
    Nvidia Quadro 600 1GB DDR3
    Primary Storage:
    2x 500GB HDD RAID 1 and Western Digital 2TB NAS RAID 1
    Secondary Storage:
    Lacie external HDD 2TB Raid Level 1
    Monitor:
    Samsung SyncMaster P2770HD, 2443 and 193T
    Discipline
    Multi-disciplinary
    Tyke's Discipline Details
    Occupation
    Surveyor, programmer, civil engineer
    Discipline
    Multi-disciplinary
    Details
    Surveying and civil engineering. As built utilities surveys and data maintenance in GIS systems. Building surveys, measured and laser scanning. Setting out of all civil works. Control and settlement surveys. Programming in AutoCAD, MicroStation, Geograf and stand alone applications for all uses.
    Using
    Civil 3D 2014
    Join Date
    Jun 2006
    Location
    Saxony, Germany
    Posts
    1,397

    Default

    Hi Matt,

    You don't actually need any VBA code to do what you want, a much better way is to use a palette. Put your block on there and just click it to insert it into a drawing. You have far more control over the whole procedure.

    There's plenty of information available. Look in Michaels Corner on this site, he's written a lot on tool palettes.

    Ben
    Engage brain before mouth

    "The German who types with a Yorkshire accent" - Dave Broada 2o1o

  3. #3
    Forum Newbie
    Using
    Architecture 2011
    Join Date
    Jul 2011
    Posts
    5

    Default

    Hi Tyke

    I use and create a lot of tool palettes, and they are awesome and I agree 100% about control. This particular instance of this block needs to come from this VBA utility. It will save the user a bunch of clicking to go to a palette.
    It is probably the only exception I have, or i would have put it on a palette.

    thanks though

    Matt


    Quote Originally Posted by Tyke View Post
    Hi Matt,

    You don't actually need any VBA code to do what you want, a much better way is to use a palette. Put your block on there and just click it to insert it into a drawing. You have far more control over the whole procedure.

    There's plenty of information available. Look in Michaels Corner on this site, he's written a lot on tool palettes.

    Ben

  4. #4
    Forum Newbie
    Using
    Architecture 2011
    Join Date
    Jul 2011
    Posts
    5

    Default

    Registered forum members do not see this ad.

    I'm getting there

    Im sorry for being a VBA dummy ....but I have one more obstacle.


    As it might be simpler to use the sendcommand, i just need help to write it.
    I am not a coder by any means....so excuse my lack of knowledge



    This code below will place the block in the drawing....great. But it places it (from user point selection), square on the drawing. I want to be able to insert the block and select the direction of the block (rotate) . Most of the time it will be in 90ยบ selections (place on drawing and go either up, down, left or right). I am guessing the sendcommand line will go after the second last line



    I can't get this rotation working at all.....sigh



    can anyone help with this lillte snippet here??


    Private Sub cmdProfileinsert_Click()

    Dim strPath As String
    Dim strBlockName As String
    Dim objBlock As AcadBlock
    Dim entRef As AcadBlockReference
    Dim dblPkPt() As Double
    strBlockName = "Profile"
    strPath = "H:\blah\blah\Profile.dwg"
    On Error Resume Next
    Set objBlock = ThisDrawing.Blocks.Item(strBlockName)
    On Error GoTo 0
    If Not objBlock Is Nothing Then objBlock.Delete 'To reinitialize Block from container file
    DbxCopyBlock strBlockName, strPath 'Copy block into ThisDrawing
    dblPkPt = ThisDrawing.Utility.GetPoint(, "Pick insertion Point: ") 'Get insertion point for test insert
    Set entRef = ThisDrawing.ModelSpace.InsertBlock(dblPkPt, "Profile", 1#, 1#, 1#, 0) 'Test insert

    End Sub

Similar Threads

  1. Block Unit Insertion ??
    By Bailey in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 23rd Apr 2014, 06:07 pm
  2. Block insertion routine based on part block file name
    By legg1979 in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 25th Aug 2013, 06:02 pm
  3. Block Insertion
    By Squirltech in forum AutoCAD General
    Replies: 4
    Last Post: 9th Sep 2012, 12:40 pm
  4. Insertion of block
    By au-s in forum AutoLISP, Visual LISP & DCL
    Replies: 18
    Last Post: 12th Feb 2009, 12:15 pm
  5. Block insertion issue
    By Hardney in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 19th Mar 2008, 04:53 pm

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