I am having trouble updating a block from file without using SendCommand.
Even if I supply if full filename in the InsertBlock method AutoCAd (220will use the local compy.
So I have to do a "SendCommand blkname=blkaname"



Registered forum members do not see this ad.
Sorry, I missed that it was 04 being used.
I am having trouble updating a block from file without using SendCommand.
Even if I supply if full filename in the InsertBlock method AutoCAd (220will 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
Thanks. Great :-)

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
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.

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.
(command "-insert" "blockname=filename")
I always mix the order of blockname and filename, but you have the method there.

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
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.
Bookmarks