+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Super Member MarcoW's Avatar
    Computer Details
    MarcoW's Computer Details
    Operating System:
    Microsoft Windows 7 Pro 64-bit
    Computer:
    A black one
    CPU:
    Intel Xeon E5520 Quad Core
    RAM:
    8 GB
    Graphics:
    NVIDIA Quadro FX 580 - 512MB
    Primary Storage:
    300 GB 10000 RPM
    Using
    AutoCAD 2011
    Join Date
    Apr 2009
    Location
    The Netherlands
    Posts
    599

    Default Insert a block by lisp: _.insert or another way?

    Registered forum members do not see this ad.

    Hi folks,

    I was wondering, if I need to make a line by lisp, I "entmake" one. When I want to make other entities, I "entmake" them also.

    When it comes to inserting a block, should I then go on the "entmake" tour again? I believe the block is already made, it needs to be inserted so not entmade. Am I right?

    I'd rather use vl-cmdf in stead of "_.insert", is that true?

    Thats all for today :-)
    Any help is very much appreciated.

    Regards,
    MarcoW.

  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

    Since that you already have made your block and existed in the current drawing , you need only to use a command to isert that block ....

    First .

    Code:
    (command "_.-insert" "YourBlockName" pause "" "" "")
    Second .

    Code:
    (vl-cmdf "_.-insert" "YourBlockName" pause "" "" "")
    By "entmakex"

    Code:
     (entmakex (list (cons 0 "INSERT")
                      (cons 2 "YourBlockName"); type you Block Name
                      (cons 10 '(0.0 0.0 0.0)))); Insertion point for your Block
    Both are the same result .

    Hope this what you meant .

    Tharwat
    Last edited by Tharwat; 2nd Nov 2010 at 10:54 am. Reason: entmakex added

  3. #3
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    678

    Default

    Entmake BLOCK to create a block
    Code:
    (defun CreatBlock ( BlkNme )
      (entmake (list (0 . "BLOCK")
          (100 . "AcDbEntity")
          (67 . 0)
          (8 . "0")
          (100 . "AcDbBlockReference")
          (cons 2 BlkNme)
          (10 0 0 0)
          (70 . 0)
         )
      )
      ;;;entmake all objects in block
     
      (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
      (princ)
    )


    Entmake INSERT to insert the block
    Code:
    (entmakex
           (list (cons 0 "INSERT")
          (cons 2 BlkNme)
          (cons 8 BlkLyr)
          (cons 10 Pnt)
          (cons 41 BlkScl)
          (cons 42 BlkScl)
          (cons 43 BlkScl)
           )
         )


    But first you have to check if the block inserted or not

    Code:
    (defun Create_Layers ()
      (if (not (tblsearch "BLOCK" "BlkNme"))
        (progn
          (CreatBlock CADTutor)
          )
        )
      )
    Sorry for my English.

  4. #4
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    678

    Default

    and Entmake is faster than calling command
    Sorry for my English.

  5. #5
    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

    Check this out

    Quote Originally Posted by MarcoW View Post
    I believe the block is already made, it needs to be inserted so not entmade. Am I right?

    I'd rather use vl-cmdf in stead of "_.insert", is that true?
    So there is no need for "entmake" since the desired Block is already made and existed in the dwg.

  6. #6
    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,548

    Default

    Marco,

    Where things can get dicey, is if the INSERT has ATTRIButes.

    For entmake:
    • the INSERT entity must contain (66 . 1) sequential entities follow flag
    • you make each ATTRIBute as a individual entity
    • you must make a SEQEND entity to finish

    For command - either:
    • Add a string value for ATTRIBute to the command sequence
    • Accept the default for each ATTRIBute value like this:
    Code:
    (while (> (getvar "CMDACTIVE") 1)
           (command ""))
    Also for the command style, you will need to check to see if an external file exists:
    Code:
    (or (tblsearch "BLOCK" block_name)
        (findfile (strcat block_name ".dwg")))
    -David
    R12 (Dos) - A2K

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,591

    Default

    vla-insertblock is a good alternative - performs faster than the command call, but no faffing around with entmake'ing Block definitions, or attributes.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    I was going to suggest vla-insertblock, but Lee beat me to it.
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  9. #9
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by Lee Mac View Post
    vla-insertblock is a good alternative - performs faster than the command call, but no faffing around with entmake'ing Block definitions, or attributes.
    And you automatically get the current annotation (if using annotative blocks) - my biggest like over entmake.
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,591

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by alanjt View Post
    And you automatically get the current annotation (if using annotative blocks) - my biggest like over entmake.
    I'll have to take your word on that one - I've never delved into the world of annotative....
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. How To Insert Block Using Lisp????
    By balajibth84 in forum AutoLISP, Visual LISP & DCL
    Replies: 33
    Last Post: 18th Oct 2010, 04:44 pm
  2. Insert Block using Lisp...HELP!!!!!????!!!!!!!
    By Chevy in forum AutoLISP, Visual LISP & DCL
    Replies: 57
    Last Post: 4th Oct 2010, 06:29 pm
  3. Help with insert block LISP
    By Demesne in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 14th May 2010, 02:01 pm
  4. block insert lisp
    By flopo in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 27th Nov 2009, 04:42 pm
  5. insert block lisp...
    By minerman in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 24th Feb 2006, 03:56 pm

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