Insert Block (One more Bug)

Discussion in 'AutoCAD' started by bkvikas, Jun 5, 2004.

  1. bkvikas

    bkvikas Guest

    Iam trying to insert a drawing file into a new drawing. below is the code.

    Dim CP1(0 To 1) As Double
    Dim ins1(0 To 2) As Double
    Dim dwg1 As String
    Dim FilePath As String
    Dim CP(0 To 2) As Double
    Dim MS As AcadModelSpace
    Dim BRO1 As AcadBlockReference
    Set MS = ThisDrawing.ModelSpace
    ins1(0) = 0: ins1(1) = 0: ins1(2) = 0
    CP(0) = 10#: CP(1) = 10#: CP(2) = 0
    FilePath = "c:/abcd/"
    dwg1 = FilePath + "rhc.dwg"
    Set BRO1 = MS.InsertBlock(ins1, dwg1, 1#, 1#, 1#, 0)

    I get an runtime error as
    "Key Not Found"

    What might be the error, iam novice to vba. please help me come out of this problem.
     
    bkvikas, Jun 5, 2004
    #1
  2. Are you an 'lisper? ;^)

    FilePath = "c:\abcd\" '<- Note: I changed to backslashes.


    Also, your ins1 array is initialized at 0,0,0 when you Dim it, so you don't
    need this line:
    ins1(0) = 0: ins1(1) = 0: ins1(2) = 0


    --
    R. Robert Bell


    Iam trying to insert a drawing file into a new drawing. below is the code.

    Dim CP1(0 To 1) As Double
    Dim ins1(0 To 2) As Double
    Dim dwg1 As String
    Dim FilePath As String
    Dim CP(0 To 2) As Double
    Dim MS As AcadModelSpace
    Dim BRO1 As AcadBlockReference
    Set MS = ThisDrawing.ModelSpace
    ins1(0) = 0: ins1(1) = 0: ins1(2) = 0
    CP(0) = 10#: CP(1) = 10#: CP(2) = 0
    FilePath = "c:/abcd/"
    dwg1 = FilePath + "rhc.dwg"
    Set BRO1 = MS.InsertBlock(ins1, dwg1, 1#, 1#, 1#, 0)

    I get an runtime error as
    "Key Not Found"

    What might be the error, iam novice to vba. please help me come out of this
    problem.
     
    R. Robert Bell, Jun 5, 2004
    #2
  3. bkvikas

    bkvikas Guest

    Oops I forgot this, So, it is wrong mentioning / in pathname.

    thanks to you , it worked perfectly.
     
    bkvikas, Jun 6, 2004
    #3
  4. Contrary to what robert says, relying on implicit
    initialization is a bad thing, because it conceals
    intent, and implies the assumption that the value
    will be initalized to 0.0 for the life of the code.
    While a change in behavior is largely improbable, it
    is not impossible.

    Explicit initialization is perfectly acceptable, and is
    considered good coding practice.


    --
    http://www.caddzone.com

    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
    http://www.acadxtabs.com
     
    Tony Tanzillo, Jun 7, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.