See the top rated post in this thread. Click here

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: How do I insert a block using AutoLISP

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

    Default Re: How do I insert a block using AutoLISP

    Both Ted's and Fixo's example routine work!!!
    Thank you guys!

    Can I please get some help with the second part of my inquiry...


    Quote Originally Posted by vladimir.karatsupa982899 View Post
    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. #12
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    9,512
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    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"
    Yes, that is the point, you set NUM to whatever you want to at run time.
    R.K. McSwain | CAD Panacea |

  3. #13
    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
    Yes, that is the point, you set NUM to whatever you want to at run time.

    Yes, I could specify "NUM" variable completely during user input however the problem is it's too much for the user to input...this is what I mean:

    For example:
    J:/123/4567/Datum_Grid/1234567_DATUM.dwg
    Here it's easy the user just enters "1234567" and later breaks it up into two variables

    But when there is text to follow the job number it's too much for the user to enter:
    J:/123/4567 - Education and Support Center/Datum_Grid/1234567_DATUM.dwg
    Here the user would have to enter "4567 - Education and Support Center"

    Is there a function of some sort where I could retrieve the text that follows after the number by just specifying the drive "J:/123/4567"
    Or any other ideas?

  4. #14
    I could stop if I wanted to devitg.89838's Avatar
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    246
    Login to Give a bone
    0

    Default Re: How do I insert a block using AutoLISP

    Last edited by devitg.89838; 2013-03-27 at 05:02 PM. Reason: cosmetic

  5. #15
    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 the assistance of block insertion into drawing.
    I would like to get some assistance on the second part of the question quoted below...

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    Yes, I could specify "NUM" variable completely during user input however the problem is it's too much for the user to input...this is what I mean:

    For example:
    J:/123/4567/Datum_Grid/1234567_DATUM.dwg
    Here it's easy the user just enters "1234567" and later breaks it up into two variables

    But when there is text to follow the job number it's too much for the user to enter:
    J:/123/4567 - Education and Support Center/Datum_Grid/1234567_DATUM.dwg
    Here the user would have to enter "4567 - Education and Support Center"

    Is there a function of some sort where I could retrieve the text that follows after the number by just specifying the drive "J:/123/4567"
    Or any other ideas?

  6. #16
    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 the assistance of block insertion into drawing.
    I would like to get some assistance on the second part of the question quoted below...

    I think this would work for you, I tried it on a similar file structure and it seemed to work ok.
    You may need to add another folder in the structure, I think you have a "Datum_Grid" folder??

    From what I'm reading, you have a file structure where you want the user to type a first set of numbers for the first part of a project number and then type a second set of numbers which is another part of the project number, and you have a constant "project name" (suffix) and a block name that uses the first two typed numbers and a constant suffix.

    Taken from RK's starter code..

    Code:
    (defun c:test (/ begin inter num projname blk)
    (setq begin "J:\\") ;;your drive letter
    (setq inter (getstring (prompt "First Numbers??"))) ;;your first project numbers XXX
    (setq num (getstring (prompt "Second Numbers??"))) ;;your second project numbers XXXX
    (setq projname " - Education and Support Center") ;;your constant project name (suffix)
    (setq blk "_datum") ;;your constant block name (suffix)
    (setq fullpath (strcat begin inter "\\" num projname "\\" inter num blk)) ;;sets the whole path from info given above
    (command "-insert" fullpath "" "" "");;edit according to how you want to handle your insert options
    )
    Hope this helps.
    Ted
    ____________________________________________________________________ ________________
    Windows 7 Professional
    AutoCAD 2017 - REVIT 2017 - Inventor Professional 2015 (when I can)

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

    Default Re: How do I insert a block using AutoLISP

    Ted,

    Sorry for my confusing writing...unfortunately the "suffix" is not a constant

    ex.1 123/4567-Education and Support Center
    ex.2 222/3333-High Rise Construction Building
    ex.3 333/4444-Childrens Hospital

    Ex.1 "suffix" = Education and Support Center
    Ex.2 "suffix" = High Rise Construction Building
    Ex.3 "suffix" = Childrens Hospital

    I am fine with asking the user to enter 123/4567 or 222/3333 or 333/4444 because I can combine this into a string (like Ted mentioned)
    but when I have to ask the user to enter the "suffix" then this code loses it's value because of a lot of typing on the user side.

    If anyone has any other suggestions on how I can achieve this task please share.



    Quote Originally Posted by tedg View Post
    I think this would work for you, I tried it on a similar file structure and it seemed to work ok.
    You may need to add another folder in the structure, I think you have a "Datum_Grid" folder??

    From what I'm reading, you have a file structure where you want the user to type a first set of numbers for the first part of a project number and then type a second set of numbers which is another part of the project number, and you have a constant "project name" (suffix) and a block name that uses the first two typed numbers and a constant suffix.

    Taken from RK's starter code..

    Code:
    (defun c:test (/ begin inter num projname blk)
    (setq begin "J:\\") ;;your drive letter
    (setq inter (getstring (prompt "First Numbers??"))) ;;your first project numbers XXX
    (setq num (getstring (prompt "Second Numbers??"))) ;;your second project numbers XXXX
    (setq projname " - Education and Support Center") ;;your constant project name (suffix)
    (setq blk "_datum") ;;your constant block name (suffix)
    (setq fullpath (strcat begin inter "\\" num projname "\\" inter num blk)) ;;sets the whole path from info given above
    (command "-insert" fullpath "" "" "");;edit according to how you want to handle your insert options
    )
    Hope this helps.

  8. #18
    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

    Are the number prefixes part of a job or project number? Will there ever be more than one suffix for one set of prefixes?

    Ex.1 123/4567-Education and Support Center
    Ex.2 123/4567-High Rise Construction Building
    Ex.3 123/4567-Childrens Hospital

    If this will not happen, you could get a list of folders from a known location. You could then filter out that list by the secondary prefix. Being it would be a parent - child folder structure, it shouldn't be too difficult.
    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

  9. #19
    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, that is precisely what I would like to do.

    That is correct there will only be one suffix for one set of prefixes...ex 123/4567 is only going to be Education and Support Center.

    How do I access a directory to get a list of folders?
    In the above example I would have to get into directory 123 then there would be a list of jobs where 4567-Education and Support Center would be one of them.

    Quote Originally Posted by Opie View Post
    ...you could get a list of folders from a known location. You could then filter out that list by the secondary prefix. Being it would be a parent - child folder structure, it shouldn't be too difficult.

  10. #20
    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 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?
    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

Page 2 of 3 FirstFirst 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
  •