+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 19 of 19
  1. #11
    Senior Member
    Computer Details
    numberOCD's Computer Details
    Operating System:
    Windows 7
    Computer:
    HP EliteBook 8770w
    RAM:
    16Gb
    Using
    MEP 2014
    Join Date
    Apr 2010
    Location
    Chicago/New York USA
    Posts
    164

    Default

    Registered forum members do not see this ad.

    Ok,
    I took out the "List" with paranthesis and the Z coordinate and it is working by pasting the line in the command bar up until the Attribute Window. It still prompts me for the Attribute value, and that is one part I need to automate badly.

    It currently reads this
    (command "_.INSERT" "SIG2" "12,36" 1 1 32 "781Z" "GYR")

  2. #12
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,515

    Default

    Leaving he Z axis value can lead to really weird results.


    Does the BLOCK have 2 or 3 Attributes?
    R12 (Dos) - A2K

  3. #13
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,515

    Default

    Quote Originally Posted by numberOCD View Post
    When I run the lsp named Test2.lsp it returns this test window
    Attachment 49920


    Thanks

    Well I guess there are file naming limitations after all

    It can only have 1 file extension ie .lsp not .lsp.shx

    Th extension cannot be .shx as the (load) command knows what a shx file is supposed to be
    R12 (Dos) - A2K

  4. #14
    Senior Member lrm's Avatar
    Computer Details
    lrm's Computer Details
    Operating System:
    Windows 7 64-bit
    RAM:
    16 GB
    Discipline
    Education
    lrm's Discipline Details
    Occupation
    Teacher, AEC and mechanical
    Discipline
    Education
    Details
    Civil and Mechanical
    Using
    AutoCAD 2014
    Join Date
    Jan 2010
    Location
    Massachusetts, USA
    Posts
    341

    Default

    Hi numberOCD,

    To answer your follow up question to my original post.

    After selecting and copying column A to the clipboard and pasting it in to MS Word you will have something that looks like this (I have turned on the display of paragraph marks and spaces):



    Use Find and Replace as shown (no spaces) to replace @@@ with ^p. The results should look something like this where each attribute beyond the first is on a new line. Make sure there is only one paragraph mark at the end of the last line and no paragraph mark after it.


    When you go to save this file in Word use Save As and then choose the txt format. This will save the file in an ASCII format. Note, you can use Notepad to edit the .scr file but Notepad's Replace function does not include paragraph character (^p).


    AutoCAD expects script files to have the file extension .scr so chnage the file name using the file manager from:

    to:


    You can then use the script command to enter all the blocks.

    For a test of this process I created a simple block named MyBlock with two attributes. The names of the attributes is not important but the order is. Please let me know if you have any questions.
    ~ lrm

  5. #15
    Senior Member lrm's Avatar
    Computer Details
    lrm's Computer Details
    Operating System:
    Windows 7 64-bit
    RAM:
    16 GB
    Discipline
    Education
    lrm's Discipline Details
    Occupation
    Teacher, AEC and mechanical
    Discipline
    Education
    Details
    Civil and Mechanical
    Using
    AutoCAD 2014
    Join Date
    Jan 2010
    Location
    Massachusetts, USA
    Posts
    341

    Default

    Here's a sample of the output of the MyBlockScript using a simple block with two attributes:


    ~lrm

  6. #16
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,727

    Default

    This works not sure why yours doesn't.

    Code:
    (command "_.insert" "labelstn" "0,0,0" 1 1 0 "10" "20" "30" "40" "50")
    A man who never made mistakes never made anything

  7. #17
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,053

    Default

    Can you upload a sample Excel file with a sample drawing that obtains the attributed blocks that you are going to use ?
    How many different attributed blocks to be inserted ?

  8. #18
    Senior Member lrm's Avatar
    Computer Details
    lrm's Computer Details
    Operating System:
    Windows 7 64-bit
    RAM:
    16 GB
    Discipline
    Education
    lrm's Discipline Details
    Occupation
    Teacher, AEC and mechanical
    Discipline
    Education
    Details
    Civil and Mechanical
    Using
    AutoCAD 2014
    Join Date
    Jan 2010
    Location
    Massachusetts, USA
    Posts
    341

    Default Adding Blocks and Attributes with a Script from Excel

    Thanks BIGAL for the suggestion. I was trying to create a script that does not use AutoLISP but it is one way around the problem of including the Enter key. It simplifies the process by eliminating the need to do a replace in Word.

    Here then is the process for converting Excel data for the location and orientation of a bunch of blocks that each include several attributes.

    1. Layout your spreadsheet similar to the following, leaving column empty. I will be using column A for building the AutoCAD command for each block through the use of the Excel Concatenate function.



    2. Type into cell A2 the following expression paying careful attention to “ and spaces. Single quotes are used to start and end a string of text while double quotes “” are used to add a single quote. I have placed red dots where spaces should be included.



    3. Use Fill-down from cell A2 to create the other AutoCAD (actually AutoLISP) commands.
    4. Copy cells A2 to A4 (or however many rows you have) to the clipboard with Ctrl-C.
    5. Open Notepad and Paste the commands into it. The file should look something like the following.



    6. Save the file in Notepad so that is has a file name extension of .scr.
    7. In an AutoCAD file that includes the definition of the blocks used give the Script command and select the .scr file.

    Here is the result.

    8. Enjoy!

    I have included the Excel, .scr, and AutoCAD file as an example.
    ~lrm
    Attached Files

  9. #19
    Senior Member
    Using
    not specified
    Join Date
    Apr 2014
    Posts
    105

    Default

    Registered forum members do not see this ad.

    Suppose that you have a txt file like this , call it "D:/A.txt" :

    MyBlock 12.34 20.5 15 Apples Bananas
    MyBlock 14.12 22.5 30 Cherries Donuts
    MyBlock 16.11 24.5 45 Eggs Figs

    You can use this lisp function to insert your block:
    Code:
    (defun c:test()
      (setq L nil
    	file (open "D:/A.txt" "r"))
      (while (setq line (read-line file))
        (setq line (mapcar 'vl-princ-to-string (read (strcat "(" line ")")))
    	  L (append L (list line)))
      )
      (close file)
      (foreach line L
        (command "-insert" (car line)
    	     (list (atof (nth 1 line)) (atof (nth 2 line)))
    	     1 1 (atof (nth 3 line))
    	     (nth 4 line) (nth 5 line)))
    )
    Using Tapatalk

Similar Threads

  1. making a bom list from blocks with attributes
    By CADkitt in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 13th Mar 2017, 08:21 am
  2. Rotate Dynamic Blocks on Insert with Option for Additional Rotate.
    By dortega4269 in forum AutoLISP, Visual LISP & DCL
    Replies: 26
    Last Post: 21st May 2013, 08:23 pm
  3. Insert blocks and rotate to polyline
    By woodman78 in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 18th Apr 2013, 06:30 pm
  4. LISP to insert blocks depending on certain attributes
    By cangelo3D in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 28th Oct 2009, 08:50 am
  5. update or insert blocks with attributes
    By serdas in forum AutoCAD General
    Replies: 24
    Last Post: 6th Nov 2008, 08:46 pm

Tags for this Thread

Bookmarks

Posting Permissions

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