+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Sep 2016
    Posts
    2

    Drawing LISP Code To Insert Block To a Drawing Template

    Registered forum members do not see this ad.

    Hello everyone,

    I'm Erick and I'm new in this forum.
    Also, I'm a beginner in creating LISP.
    I need your help to create a code that will do the following items.
    1. Automatic insert of a block (this .DWG block can be found on the same directory as the drawing template) to an open drawing template.
    2. During insert, LISP should put the block in fixed location (0, 0), then scale it to a fixed scale factor (i.e. 0.5, 0.5) and will have a fixed rotation (0 deg).

    Thank you in advance.
    Hoping you'll help me on this first project.
    Attached Files
    Last edited by erickson19886; 6th Sep 2016 at 09:27 am. Reason: Add attachment

  2. #2
    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 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Hi Erick, welcome to CADTutor.

    Here is a start for you to test out and also you can use the command call "-insert" as well if you find the vla-* functions hard to deal with at the mean time.
    Code:
    (vla-insertblock
      (vla-get-modelspace
        (vla-get-activedocument (vlax-get-acad-object)))
      (vlax-3d-point '(0. 0. 0.))
      "C:\\Users\\Tharwat\\Desktop\\Drawing1.dwg" ;; Replace this path of drawing with yours
      0.5
      0.5
      1.0
      0.)

  3. #3
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Sep 2016
    Posts
    2

    Default

    Quote Originally Posted by Tharwat View Post
    Hi Erick, welcome to CADTutor.

    Here is a start for you to test out and also you can use the command call "-insert" as well if you find the vla-* functions hard to deal with at the mean time.
    Code:
    (vla-insertblock
      (vla-get-modelspace
        (vla-get-activedocument (vlax-get-acad-object)))
      (vlax-3d-point '(0. 0. 0.))
      "C:\\Users\\Tharwat\\Desktop\\Drawing1.dwg" ;; Replace this path of drawing with yours
      0.5
      0.5
      1.0
      0.)
    Hi Tharwat,
    Good day.
    Thanks a lot for the helpful code that you just shared.
    It really works the way I planned it to.
    Also, this is a good start for me. I will just do some study to understand the code.

  4. #4
    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 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Good luck and happy coding.

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

    Default

    You may want to look at tool palettes if your going to do this for lots of blocks, maybe something like this older method via menu's.
    Attached Images
    A man who never made mistakes never made anything

  6. #6
    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 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Registered forum members do not see this ad.

    The OP needs codes to use and to learn from it and that's why they posted in AutoLISP forum.

Similar Threads

  1. Any suggestion code lisp for fulfill text in template ??
    By hosyn in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 5th Dec 2015, 12:30 am
  2. Script to insert title block template
    By callvey in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 4
    Last Post: 26th Jun 2014, 02:12 pm
  3. Drawing template won't insert in layout
    By amsmarle in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 14th Sep 2012, 04:40 pm
  4. code to insert dynamic block
    By kloe in forum .NET, ObjectARX & VBA
    Replies: 2
    Last Post: 11th Nov 2010, 05:29 am
  5. Code Lisp about Insert a Block in a Table Cell
    By Tue_NV in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 14th May 2010, 08:46 am

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