inserting a block by pathname using activex automation

Using Visual Basic, how do youinsert a block by pathname using activex automation (object model)?AutoCAD 2000 lets you specify either a pathname or a block namefor inserting a block object reference. However, after much experimentation,it seems to me that IntelliCAD 2000 will not let you specify a pathname(e.g. "c:\dwgfiles\ablock.dwg"), but only the block name ("ablock"). Thiscreates a problem, because I want the program to automatically insert many blocksby pathname, and not force the user to insert the each block using ddinsert.I tried setting the default block path name to search for blocks to be "c:\dwgfiles", but this did not help.Any suggestions or assistance in this matter will be greatly appreciated.

Comments

  • Hi,I didn't find a method that does this directly. You can use the following to do what you need:Public Sub test() Dim Filename As String 'as object so you don't have to reference the Microsoft Scripting runtime library Dim FSO As Object 'use CreateObject to not have to reference the library mentioned above Set FSO = CreateObject("scripting.filesystemobject") Filename = "c:\data\model.dwg" 'cannot have spaces in pathname Filename = FSO.GetFile(Filename).shortpath Application.RunCommand "insert " & Filename & _ " 0,0,0 1 1 1 0 " Set FSO = NothingEnd SubHope this helps you out.

This discussion has been closed.