See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: How do I insert a block using AutoLISP

  1. #1
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default How do I insert a block using AutoLISP

    This question will consist of two parts:
    1. How do I insert a block using AutoLISP and
    2. How can I build "string" of characters to work as browse search path if it constantly changes.


    Part One:
    To insert this block I want to use the browse feature linking to the origin because this way if the block has changed it will update upon insertion.

    Part Two"
    When I use the browse feature to find a block I would like to input manually the sections of an address the address path that I am looking at has a variable that always is different from job to job.
    ex. V:\\XXX\\XXXX - First Job\\Datum.dwg vs. V:\\XXX\XXXX - Second Job\\Datum.dwg vs. V:\\XXX\\XXXX - Third Job\\Datum.dwg

    XXX\\... (stays the same)
    ....\\Datum.dwg (stays the same)
    ...XXXX - First Job (would always be different)

    Is there a way to compile an address path by just specifying the 4 x's (XXXX) and ignoring the " - First Job\\" part?

    Thank you

  2. #2
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Any suggestions???
    Anyone???

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

    Default Re: How do I insert a block using AutoLISP

    How would you normally insert a block? Do you know how to do that from the command line?

    You could look at the getfiled AutoLISP function to allow you to graphically browse for a file or a folder.
    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

  4. #4
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    9,513
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    Is there a way to compile an address path by just specifying the 4 x's (XXXX) and ignoring the " - First Job\\" part?
    Thank you
    Use (strcat) to build the desired string

    Code:
    (setq num "7734\\")
    (setq begin "\\\\server\\path\\")
    (setq inter "projects\\")
    (setq name "myblock")
    (setq full (strcat begin inter num name))
    ;;; full = "\\\\server\\path\\projects\\7734\\myblock"
    R.K. McSwain | CAD Panacea |

  5. #5
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Quote Originally Posted by Opie View Post
    How would you normally insert a block? Do you know how to do that from the command line?
    Please correct me if I'm wrong...when I use the regular (command "insert" ) I am able to only insert the block that is in my drawing, I wouldn't be able to browse for a block.

    Quote Originally Posted by Opie View Post
    You could look at the getfiled AutoLISP function to allow you to graphically browse for a file or a folder.
    Please correct me if I'm wrong...if I use the getfiled function I would insert the block into the drawing which later I can insert using the (command "insert"), the drawback of this is (command "insert") would never insert the block from the origin, hence if I update my block I wouldn't see the changes.

  6. #6
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Quote Originally Posted by rkmcswain View Post
    Use (strcat) to build the desired string

    Code:
    (setq num "7734\\")
    (setq begin "\\\\server\\path\\")
    (setq inter "projects\\")
    (setq name "myblock")
    (setq full (strcat begin inter num name))
    ;;; full = "\\\\server\\path\\projects\\7734\\myblock"
    The "catch" is in the fact that using your example "NUM" variable constantly changes from being #### (4 digits) to ####-abcd (4 digits-text)
    I would like to specify ONLY #### (4 digits) in the initial user input eliminating the "-abcd"

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

    Default Re: How do I insert a block using AutoLISP

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    Please correct me if I'm wrong...when I use the regular (command "insert" ) I am able to only insert the block that is in my drawing, I wouldn't be able to browse for a block.
    Okay, you are wrong. The (command "insert") will insert a block either from the drawing or will search in your Support Files Search Path for a drawing containing the same name of the block. You can also specify a directory and filename combination when inserting a block.

    Please correct me if I'm wrong...if I use the getfiled function I would insert the block into the drawing which later I can insert using the (command "insert"), the drawback of this is (command "insert") would never insert the block from the origin, hence if I update my block I wouldn't see the changes.
    Again, you are wrong. The getfiled function provides a graphical interface allowing the user to navigate to a desired file. It returns that directory / filename combination to your AutoLISP routine. It does not insert any block from that function. You would need to handle that string value in your program to do what you want it to do.

    I only suggested you write down your workflow on how you would manually do this task. Once you have this workflow written out, you can begin to start converting those steps into the program you are trying to create.
    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

  8. #8
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Thank you for correcting me...

    In my case the block that I would like to insert is not in just one file directory it is attached to every job folder.

    What am I doing wrong in the following routine

    (command "insert")
    Enter block name or [?] J:\\123\\4567\\00\\Prod\\Xref\\Datum_Grid\\1234567_DATUM.dwg
    Invalid block name

    I tried entering "?" and then pasting the address...but no luck

  9. #9
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,104
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    Thank you for correcting me...

    In my case the block that I would like to insert is not in just one file directory it is attached to every job folder.

    What am I doing wrong in the following routine

    (command "insert")
    Enter block name or [?] J:\\123\\4567\\00\\Prod\\Xref\\Datum_Grid\\1234567_DATUM.dwg
    Invalid block name

    I tried entering "?" and then pasting the address...but no luck
    Are you doing this on the command line or in a lisp?
    Is the block named "1234567_DATUM"?

    Try on the command line: (note the single slashes, no "dwg" suffix)
    Code:
    -insert
    J:\123\4567\00\Prod\Xref\Datum_Grid\1234567_DATUM
    Or in a lisp:
    Code:
    (command "-insert" "J:\\123\\4567\\00\\Prod\\Xref\\Datum_Grid\\1234567_DATUM" ...
    Ted
    ____________________________________________________________________ ________________
    Windows 7 Professional
    AutoCAD 2017 - REVIT 2017 - Inventor Professional 2015 (when I can)

  10. #10
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Ted, I'm not sure but perhaps like this would not work?
    Code:
    (command "-insert" "blockname=J:/123/4567/00/Prod//Xref/Datum_Grid/1234567_DATUM.dwg" ...)
    "The whole problem with the world is that fools and fanatics are always
    so certain of themselves, and wiser people so full of doubts."
    Bertrand Russell

Page 1 of 3 123 LastLast

Similar Threads

  1. Insert a Tool Palette Block While Editing a Block or Xref.
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2013-10-07, 04:53 PM
  2. Block Insert - Right Click Block Open Drawing
    By Texan1 in forum ACA Wish List
    Replies: 1
    Last Post: 2011-11-26, 04:38 AM
  3. AutoLISP function to get values of existing dynamic block insert
    By truevis in forum Dynamic Blocks - Technical
    Replies: 0
    Last Post: 2007-11-17, 04:34 PM
  4. Replies: 19
    Last Post: 2006-03-14, 05:06 PM

Tags for this Thread

Posting Permissions

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