Results 1 to 5 of 5

Thread: How do use vla-item to select an open drawing

  1. #1
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default How do use vla-item to select an open drawing

    I have a lisp routine that creates a new drawing from the active drawing using EXPORTTOAUTOCAD, then opens it. Since I know the file name (having just created it) I want this drawing to become the active drawing using vla-item. When I run this code:

    (setq Filename "C:\\ProjDir\\NewDrawing.dwg")
    (vla-item (vla-get-documents (vlax-get-acad-object)) Filename) I get this error:

    error: Automation Error. Description was not provided.

    This code works just fine however:

    (setq Filename "C:\\ProjDir\\NewDrawing.dwg")
    (vlax-for dwg (vla-get-documents (vlax-get-acad-object))
    (if (= (vla-get-FullName dwg) FileName) (vla-activate dwg)))

    Can someone please explain how to use vla-item with a known drawing name to get the vla-object out of the documents collection?

    Thanks

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: How do use vla-item to select an open drawing

    Hi,

    Like this:
    Code:
    (vla-item (vla-get-documents (vlax-get-acad-object)) (strcat (vl-filename-base FileName) (vl-filename-extension FileName)))

  3. #3
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Re: How do use vla-item to select an open drawing

    Thanks for the help. It turns out that my code didn't work becausr I was using some lower-case letters in my text string whereas AutoCAD was using all upper-case for the drawing name and rejecting the match. When I feed vla-item the string with all upper-case, it works fine. Seems a little bit lame to me but at least I figured it out. Thanks again.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: How do use vla-item to select an open drawing

    You are welcome.

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,104
    Login to Give a bone
    0

    Default Re: How do use vla-item to select an open drawing

    Quote Originally Posted by deheylen690271 View Post
    Thanks for the help. It turns out that my code didn't work becausr I was using some lower-case letters in my text string whereas AutoCAD was using all upper-case for the drawing name and rejecting the match. When I feed vla-item the string with all upper-case, it works fine. Seems a little bit lame to me but at least I figured it out. Thanks again.
    Yes, when comparing text, the case needs to match on both sides of the comparison.

    Glad you figured it out.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Similar Threads

  1. Replies: 10
    Last Post: 2023-01-24, 06:27 PM
  2. Detail Item Drawing Order
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2012-08-07, 05:57 PM
  3. 2011: Is Shift Window Select Grips a wishlist item?
    By 3dway in forum AutoCAD General
    Replies: 5
    Last Post: 2010-07-29, 08:54 PM
  4. Unable to select more than one item...
    By ojhicks-bhm in forum AutoCAD LT - General
    Replies: 5
    Last Post: 2007-02-22, 04:38 PM
  5. Open drawing file - "Select Shape File" message appears
    By gdgutie in forum AutoCAD General
    Replies: 5
    Last Post: 2006-02-07, 05:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •