+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 22
  1. #11
    Super Member
    Using
    Architecture 2009
    Join Date
    Apr 2008
    Location
    London, (sunny UK)
    Posts
    686

    Default

    Registered forum members do not see this ad.

    Sorry, I missed that it was 04 being used.

  2. #12
    Super Member Raggi_Thor's Avatar
    Using
    AutoCAD 2008
    Join Date
    Aug 2007
    Location
    Trondheim, NORWAY
    Posts
    718

    Default

    I am having trouble updating a block from file without using SendCommand.
    Even if I supply if full filename in the InsertBlock method AutoCAd (220 will use the local compy.
    So I have to do a "SendCommand blkname=blkaname"
    Mvh, Kvedja, Kind Regards,
    Ragnar Thor Mikkelsen
    http://www.DESIGNDATA.no/English.htm

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

    Default

    Quote Originally Posted by Raggi_Thor View Post
    I am having trouble updating a block from file without using SendCommand.
    Even if I supply if full filename in the InsertBlock method AutoCAd (220 will use the local compy.
    So I have to do a "SendCommand blkname=blkaname"
    The general method shown below will update the geometry of a block. Extra steps would be required if attached Attributes are also modified.

    Make note of the line:

    Set ACDbx = ThisDrawing.Application.GetInterfaceObject("Object DBX.AxDbDocument.16") 'set to appropriate version

    in the attached code.

    Code:
    Sub SetBlocks() 'Change as required
    Dim strPath As String
    Dim strBlockName As String
    Dim objBlock As AcadBlock
       strBlockName = "Tester"
       strPath = "C:\"
       BlockRedefine strBlockName, strPath
    End Sub
    
    Private Sub BlockRedefine(strBlockName As String, strPath As String)
    Dim strFullDef As String
    Dim objBlock As AcadBlock
    Dim entEnt As AcadEntity
       On Error GoTo BlockNotAvailable
       Set objBlock = ThisDrawing.Blocks.Item(strBlockName)
       On Error GoTo 0
       For Each entEnt In objBlock
          entEnt.Delete
       Next
       strFullDef = strPath & strBlockName & ".dwg"
       DbxTransfer strFullDef, objBlock
       For Each entEnt In objBlock
          entEnt.Update
       Next
       For Each entEnt In ThisDrawing.ModelSpace
          entEnt.Update
       Next
          For Each entEnt In ThisDrawing.PaperSpace
          entEnt.Update
       Next
    BlockNotAvailable:
    End Sub
    
    Private Sub DbxTransfer(strFullFile As String, objBlock As AcadBlock)
    Dim entEntities() As Object
    Dim varReturn As Variant
    Dim ACDbx As AxDbDocument
    Dim intCount As Integer
       Set ACDbx = ThisDrawing.Application.GetInterfaceObject("ObjectDBX.AxDbDocument.16") 'set to appropriate version
       ACDbx.Open strFullFile
       intCount = ACDbx.ModelSpace.Count
       ReDim entEntities(intCount - 1)
       For intCount = 0 To ACDbx.ModelSpace.Count - 1
          Set entEntities(intCount) = ACDbx.ModelSpace.Item(intCount)
       Next
       ACDbx.CopyObjects entEntities, objBlock
    End Sub

  4. #14
    Super Member Raggi_Thor's Avatar
    Using
    AutoCAD 2008
    Join Date
    Aug 2007
    Location
    Trondheim, NORWAY
    Posts
    718

    Default

    Thanks. Great :-)
    Mvh, Kvedja, Kind Regards,
    Ragnar Thor Mikkelsen
    http://www.DESIGNDATA.no/English.htm

  5. #15
    Full Member
    Computer Details
    frostrap's Computer Details
    Operating System:
    Windows Vista
    Using
    AutoCAD 2009
    Join Date
    Dec 2007
    Location
    Tacoma, Wa, USA
    Posts
    80

    Default

    One of the reasons that i want to be able to envoke the insert command without using a command is because I don't want autocad to recall "-insert" as the last command that was used.

    Since it looks like the only way to get dynamic feedback is by envoking the insert command, is there any way to effectively change what autocad recalls was the last command used?

    I don't think there's a way to do this using just VBA, but perhaps Lisp or Vlisp has some answer?

    Since I don't know C++ and there's no .Net API for r16, ARX options are probably out of the picture for the time being. Unless you think the switch from VBA to C++ is one that could be made without too much craziness.

    There must be a solution for this because I've seen this done by a program that already exists (i'm trying to reverse engineer portions of it).

    Thanks again.

    joe

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

    Default

    I would imagine any of those other language options would accomplish the task more easily than VBA. Quite frankly, with Dynamic Feedback and Command Line interaction, you are dealing with two of VBA’s most celebrated shortcomings.

    The drawback to employing one of the other options is the overhead dealing with the mixed code base – if you plan on maintaining your existing VBA code. Not insurmountable, I understand, but no doubt a PITA.

  7. #17
    Full Member
    Computer Details
    frostrap's Computer Details
    Operating System:
    Windows Vista
    Using
    AutoCAD 2009
    Join Date
    Dec 2007
    Location
    Tacoma, Wa, USA
    Posts
    80

    Default

    Is there any way to do what I'm looking to do in VisualLisp?

    The program I'm using as a model to improve upon seems to be a compiled vlx file, and it is capable of handling dynamic insertions... there must be a way to do what I'm looking to do.

  8. #18
    Super Member Raggi_Thor's Avatar
    Using
    AutoCAD 2008
    Join Date
    Aug 2007
    Location
    Trondheim, NORWAY
    Posts
    718

    Default

    (command "-insert" "blockname=filename")

    I always mix the order of blockname and filename, but you have the method there.
    Mvh, Kvedja, Kind Regards,
    Ragnar Thor Mikkelsen
    http://www.DESIGNDATA.no/English.htm

  9. #19
    Full Member
    Computer Details
    frostrap's Computer Details
    Operating System:
    Windows Vista
    Using
    AutoCAD 2009
    Join Date
    Dec 2007
    Location
    Tacoma, Wa, USA
    Posts
    80

    Default

    Well, in order to solve a few issues, I ended up passing the filename/path, and a slew of other variables to a lisp routine via the "USER**" variables.

    That routine picks up where the VBA falls short and handles the ghosting and whatnot just great. I had to get a little tricky with the NOMUTT variable to get things to look right, but it seems to work like a charm.

    Am I right in assuming that vb.net or C++ would have been able to do the ghosting without scripting the .-insert command via Lisp?

    Thanks for all of your help!

    Joe

  10. #20
    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.

    JIGGING is the .Net term for ghosting. Jigs allow .net the ability to display temporary graphics before commiting the elements to the drawing database.

    In the case of block insertion, I believe Autodesk.AutoCAD.EditorInput.DrawJig or
    Autodesk.AutoCAD.EditorInput.EntityJig would be the ticket.

Similar Threads

  1. Inserting Blocks
    By Michael Henson in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 6th Feb 2008, 04:00 pm
  2. Inserting blocks
    By edortizr6 in forum AutoCAD Beginners' Area
    Replies: 21
    Last Post: 7th Nov 2007, 06:30 pm
  3. Inserting Blocks
    By happyunited in forum AutoCAD Drawing Management & Output
    Replies: 11
    Last Post: 23rd Jul 2007, 04:27 pm
  4. Inserting blocks
    By johnengineer in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 25th Apr 2007, 05:01 pm
  5. Inserting blocks
    By misha in forum AutoCAD General
    Replies: 1
    Last Post: 1st Jun 2006, 02:33 am

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