+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23
  1. #1
    Junior Member
    Computer Details
    deejaydave's Computer Details
    Operating System:
    Windows 7
    Discipline
    Multi-disciplinary
    deejaydave's Discipline Details
    Occupation
    Autocad Technician
    Discipline
    Multi-disciplinary
    Details
    Earth and water resources (quarry design, water management etc)
    Using
    AutoCAD 2015
    Join Date
    Jul 2016
    Location
    Oxfordshire, England
    Posts
    13

    Default Using a text file to add and manipulate Dynamic Blocks

    Registered forum members do not see this ad.

    I am trying to find out if you can use a text file (converted from a spreadsheet) to add dynamic blocks to a drawing, not just the X, Y coordinates, but the angle (not standard rotation, the dynamic one). The block I am working with reflects “Dip & Strike”. The block has only three (3) dynamic variables, Angle, Basepoint and Visibility Drop List. I want to automate adding multiple blocks without having to change the angle one at a time.
    Any help would be appreciated.

  2. #2
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    Go to the source WWW.lee-mac.com and get his dynamic block lisp. You could read a text file insert the block then pass all the required values to your dynamic block. If you dont know how to use lisp post a dwg and a text file. A good subject to learn about. Note also can do csv files.
    A man who never made mistakes never made anything

  3. #3
    Junior Member
    Computer Details
    deejaydave's Computer Details
    Operating System:
    Windows 7
    Discipline
    Multi-disciplinary
    deejaydave's Discipline Details
    Occupation
    Autocad Technician
    Discipline
    Multi-disciplinary
    Details
    Earth and water resources (quarry design, water management etc)
    Using
    AutoCAD 2015
    Join Date
    Jul 2016
    Location
    Oxfordshire, England
    Posts
    13

    Default RE: Using a text file to add and manipulate Dynamic Blocks

    Thanks for the reply BIGAL, unfortunately none of Dynamic Block lisp files will help me achieve exactly what I want. I have a feeling that bulk manipulation of dynamic blocks is not a simple task and not easily solved.

  4. #4
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    You can do what you want ! Look at a simple rectangle dynamic block length & width are dynamic so a text file would look like this.


    Code:
    x y len wid
    1 2 12.45 12.56
    10 10 10 10
    You would read the line and set the variables x,y Len & WId insert dynamic block x,y 1 1 0 then update the dynamic block with correct Length & width.

    You can cut the middle man out if you want and just read direct form excel, but lets crawl before we run.


    Post your dwg with the block.
    A man who never made mistakes never made anything

  5. #5
    Junior Member
    Computer Details
    deejaydave's Computer Details
    Operating System:
    Windows 7
    Discipline
    Multi-disciplinary
    deejaydave's Discipline Details
    Occupation
    Autocad Technician
    Discipline
    Multi-disciplinary
    Details
    Earth and water resources (quarry design, water management etc)
    Using
    AutoCAD 2015
    Join Date
    Jul 2016
    Location
    Oxfordshire, England
    Posts
    13

    Default

    Thanks. I have attached a drawing containing the block.


    I appreciate the help.


    deejaydave
    Attached Files

  6. #6
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    Try this

    Code:
    ; dynamic block insert from csv
    ; by Alan H July 2018
    
    ; thanks to Lee-mac for this defun and the dynamic block put defun
    (defun _csv->lst ( str / pos )
    (if (setq pos (vl-string-position 44 str))
        (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
        (list str)
        )
    )
    
    ;The dtr function converts degrees to radians
    ;The rtd function converts radians to degrees
    (defun dtr (a)
    (* pi (/ a 180.0))
    )
    
    (defun LM:setdynpropvalue ( blk prp val )
        (setq prp (strcase prp))
        (vl-some
           '(lambda ( x )
                (if (= prp (strcase (vla-get-propertyname x)))
                    (progn
                        (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                        (cond (val) (t))
                    )
                )
            )
            (vlax-invoke blk 'getdynamicblockproperties)
        )
    )
    
    (defun AH:setdyn ( / obj att fo x y ang oldattdia )
    (setq oldattdia (getvar 'attdia))
    (setvar "attdia" 0)
    (setq fo (open (getfiled "Text Export File" "" "csv" 4) "R"))
    (while (setq newline(read-line fo))
    (setq lst (_csv->lst newline))
    (setq x (atof (nth 0 lst)))
    (setq y (atof (nth 1 lst)))
    (setq ang (nth 2 lst))
    (setq dynvar (nth 3 lst))
    (command "insert" "DIP_STRIKE" (list x y) 1 1 0)
    (setq obj (vlax-ename->vla-object (entlast)))
    (LM:setdynpropvalue  obj "Angle1"   ( - 0.0 (dtr (atof ang))))
    (LM:setdynpropvalue  obj "Visibility1" dynvar)
    )
    (close fo)
    (command "Regen")
    (setvar 'attdia oldattdia)
    (princ)
    )
    Save this as say test.csv
    Code:
    100,100,45,With Arrowhead
    200,5,32,With pointer
    -200,-200,14,ArrowHead Without Strike
    300,200,90,Pointer Without Strike
    Last edited by BIGAL; 7th Jul 2018 at 03:50 am.
    A man who never made mistakes never made anything

  7. #7
    Junior Member
    Computer Details
    deejaydave's Computer Details
    Operating System:
    Windows 7
    Discipline
    Multi-disciplinary
    deejaydave's Discipline Details
    Occupation
    Autocad Technician
    Discipline
    Multi-disciplinary
    Details
    Earth and water resources (quarry design, water management etc)
    Using
    AutoCAD 2015
    Join Date
    Jul 2016
    Location
    Oxfordshire, England
    Posts
    13

    Default

    BIGAL


    Thanks for the code. Unfortunately it has done something to the angles, it shows 14° when it should be 346°. It seems to have reverted to AutoCAD's setup, I work on the principal of 0° = N, 180°=S etc.
    The code might come in handy for other blocks in the future, so a big thanks for the work.


    Regards
    deejaydave

  8. #8
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    We spend a lot of time doing something to try and just saying oh angles are wrong will not get you much support in future, it can be fixed, we have limited info to go on when trying to solve a problem and it may take a couple of attempts, angle in AutoCAD can be controlled. take the 4 examples and post an image of what they should be.
    A man who never made mistakes never made anything

  9. #9
    Junior Member
    Computer Details
    deejaydave's Computer Details
    Operating System:
    Windows 7
    Discipline
    Multi-disciplinary
    deejaydave's Discipline Details
    Occupation
    Autocad Technician
    Discipline
    Multi-disciplinary
    Details
    Earth and water resources (quarry design, water management etc)
    Using
    AutoCAD 2015
    Join Date
    Jul 2016
    Location
    Oxfordshire, England
    Posts
    13

    Default

    I was just being specific, sorry if it sounded otherwise.


    I have attached the test drawing from before with a few annotations (direction of rotation, degree points etc). I hope this helps.


    (Question. The language code used, what is it?)


    Thanks very much for the help.
    Regards
    deejaydave
    Attached Files

  10. #10
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    Registered forum members do not see this ad.

    Hopefully fixed just removed the attribute update and inserted in a different way. Code updated.

    The code is written in lisp and Visual Lisp, Autocad Lisp has been around since day dot, and visual lisp was introduced years ago adding more functions. The majority here of code is lisp and a bit of VBA and some .Net which is a high level programming approach.
    A man who never made mistakes never made anything

Similar Threads

  1. Dynamic blocks and text rotation....
    By pingsb in forum AutoCAD Drawing Management & Output
    Replies: 9
    Last Post: 25th Sep 2017, 01:47 pm
  2. dynamic text with dynamic blocks
    By jpd in forum AutoCAD Drawing Management & Output
    Replies: 20
    Last Post: 6th Aug 2013, 06:06 pm
  3. Insert dynamic block from file with multiple dynamic blocks
    By BUrBaKy in forum AutoCAD Drawing Management & Output
    Replies: 17
    Last Post: 14th Nov 2012, 11:38 pm
  4. Dynamic Blocks and Text
    By Jabaker in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 3
    Last Post: 19th Aug 2010, 10:32 am
  5. Dynamic blocks and file size
    By Grendel in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 8th Apr 2009, 06:37 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