See the top rated post in this thread. Click here

Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: How do I insert a block using AutoLISP

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

    Default Re: How do I insert a block using AutoLISP

    I envision the routine asking the user 7 digits (ex. 1234567) and by using those 7 digits I want to compile a string of the full address path.

    (setq drive "J:\\")
    (setq job (getstring "\nWhat is the job number (enter with no dashes)? "))
    (setq job1 (substr job 1 3))
    (setq job2 (substr job 4 4))
    ;;;(setq suffix (substr job2 ????? this is where I would need the function that would look up the suffix by using job2 (4567) variable
    (setq addresspath (strcat drive job1"\\"job2"-"suffix)

    ...then I would use the addresspath to insert the datum

    Quote Originally Posted by Opie View Post
    How do you envision this routine to operate? Do you want to request a project number combination? Or have the user browse for the necessary folder?

  2. #22
    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

    Once you have the first part of the path, use the vl-directory-files function with the with the second part as a pattern to look for and filter for directories only.

    Code:
    (setq drive   "J:\\"
          job     (getstring "\nSpecify job number (without dashes): ")
          prefix1 (substr job 1 3)
          prefix2 (substr job 4 4)
          project (vl-directory-files
    		(strcat drive prefix1)
    		(strcat prefix2 "*.")
    		-1
    	      )
    )
    You may have to adjust this code regarding the vl-directory-files function as I haven't tested it. My folder structure is completely different.
    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

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

    Default Re: How do I insert a block using AutoLISP

    This code works perfectly

    I do have a question though...my project variable gives me the result in a ("text_text_text") format how do I remove the ()'s and make this line a piece of text?



    Quote Originally Posted by Opie View Post
    Once you have the first part of the path, use the vl-directory-files function with the with the second part as a pattern to look for and filter for directories only.

    Code:
    (setq drive   "J:\\"
          job     (getstring "\nSpecify job number (without dashes): ")
          prefix1 (substr job 1 3)
          prefix2 (substr job 4 4)
          project (vl-directory-files
    		(strcat drive prefix1)
    		(strcat prefix2 "*.")
    		-1
    	      )
    )
    You may have to adjust this code regarding the vl-directory-files function as I haven't tested it. My folder structure is completely different.

  4. #24
    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

    the car function will give you the first element of that list.
    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

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

    Default Re: How do I insert a block using AutoLISP

    The code works perfectly!!!

    I wanted to thank everyone who has helped me get this task accomplished.
    I have learned a lot...ironically this is what this user group is all about

  6. #26
    Woo! Hoo! my 1st post
    Join Date
    2018-05
    Posts
    1
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    This post is old; however, the answer to your question is:
    1. set support file search path to the location of the block:
    2. open note pad. copy and paste the information (replace "ENTER BLOCK NAME HERE" with the name of the file you want to insert)

    (command "attdia" "0")
    (command "attreq" "0")
    (command "-insert" "ENTER BLOCK NAME HERE" "0,0" "1" "1" "0")
    (command "attdia" "1")
    (command "attreq" "1")

Page 3 of 3 FirstFirst 123

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
  •