harrison-matt Posted February 26, 2010 Posted February 26, 2010 Lee, I have been command calling in most of my lisps and am now attempting to convert those codes and my thoughts on coding. Could you help a poor sap out? I am especially interested in seeing "MLINE" in use. Any direction and further explanation would be greatly appreciated. -Matt Quote
Lee Mac Posted February 26, 2010 Author Posted February 26, 2010 Hi Matt, I have never 'entmade' an MLINE... I shall have to investigate... Quote
harrison-matt Posted February 26, 2010 Posted February 26, 2010 Thanks Lee, But trully I am a beginner in the world away from command calling, any suggestions as to where the wind should blow? Quote
Lee Mac Posted February 26, 2010 Author Posted February 26, 2010 Here is the reference that I use when using entmake http://autodesk.com/techpubs/autocad/acad2000/dxf/ Quote
devitg Posted March 8, 2010 Posted March 8, 2010 Thanks Lee, But trully I am a beginner in the world away from command calling, any suggestions as to where the wind should blow? Hi Harrison Mat, since I discover VL functions I jump form COMMAND to VLA-ADDxxxx It is far simple to use , some trick to learn and then a piece off cake. See a sample I made to convert a a lwpolyline in a Mline polis-a-mline.LSP Quote
The Buzzard Posted March 8, 2010 Posted March 8, 2010 Hi Harrison Mat, since I discover VL functions I jump form COMMAND to VLA-ADDxxxx It is far simple to use , some trick to learn and then a piece off cake. See a sample I made to convert a a lwpolyline in a Mline But entmake runs much faster then command calls or VL. Quote
devitg Posted March 8, 2010 Posted March 8, 2010 But entmake runs much faster then command calls or VL. I never do speed test on it Quote
The Buzzard Posted March 8, 2010 Posted March 8, 2010 I never do speed test on it See this link: http://cadpanacea.com/node/107 Quote
devitg Posted March 8, 2010 Posted March 8, 2010 See this link: http://cadpanacea.com/node/107 Thanks for the link I learn a new one today. Gabriel. Quote
Lee Mac Posted March 8, 2010 Author Posted March 8, 2010 IMO, some things are easier in Vanilla LISP, and some easier in Visual. Quote
Kerry Brown Posted March 9, 2010 Posted March 9, 2010 Unless you are drawing thousands of entitys the difference between entmake and VL is not that much. just for info, the panacea link forgot about (vlax-invoke ... which does NOT require lists being converted to vlax-3D-Points (see Test14) For instance, try these (defun date->sec (/ s) (setq s (getvar "DATE")) (* 86400.0 (- s (fix s))) ) (defun c:test11 (/ i timer) (setvar "cmdecho" 0) (setvar "nomutt" 1) (setvar "OSMODE" 0) (setq i 1 timer (date->sec) ) (while (< i 1000) (command "._line" (list i i 0.0) (list (+ 2 i) (1+ i) 0.0) "") (setq i (1+ i)) ) (alert (rtos (- (date->sec) timer) 2 6)) (setvar "cmdecho" 1) (setvar "nomutt" 0) ) (defun c:test12 (/ i timer) (setq i 1 timer (date->sec) ) (while (< i 1000) (entmake (list (cons 0 "LINE") (cons 10 (list i i 0.0)) (cons 11 (list (+ 2 i) (1+ i) 0.0)) ) ) (setq i (1+ i)) ) (alert (rtos (- (date->sec) timer) 2 6)) ) (defun c:test13 (/ ms i timer) (vl-load-com) (setq i 1 timer (date->sec) ) (setq ms (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)) ) ) (while (< i 1000) (vla-addline ms (vlax-3d-point (list i i 0.0)) (vlax-3d-point (list (+ 2 i) (1+ i) 0.0)) ) (setq i (1+ i)) ) (alert (rtos (- (date->sec) timer) 2 ) ) (defun c:test14 (/ ms i timer) (vl-load-com) (setq i 1.0 timer (date->sec) ) (setq ms (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)) ) ) (while (< i 1000) (vlax-invoke ms 'addline (list i i 0.0) (list (+ 2 i) (1+ i) 0.0) ) (setq i (1+ i)) ) (alert (rtos (- (date->sec) timer) 2 ) ) Regards Kerry Quote
rkmcswain Posted March 9, 2010 Posted March 9, 2010 Unless you are drawing thousands of entitys the difference between entmake and VL is not that much.I agree. just for info, the panacea link forgot about (vlax-invoke ... which does NOT require lists being converted to vlax-3D-Points (see Test14) Good point. Thanks for the reminder. I'll add a link to your post here. For instance, try these.... I changed the (alert) calls to (princ) and looped it a few times. Here are the results I got: Command: (repeat 5 (progn (c:test11)(c:test12)(c:test13)(c:test14))) Command: 0.797018 Entmake: 0.046992 VLA1: 0.18700361 VLA2: 0.12500435 Command: 0.687021 Entmake: 0.063005 VLA1: 0.17199665 VLA2: 0.12500435 Command: 0.703999 Entmake: 0.045986 VLA1: 0.18800944 VLA2: 0.12500435 Command: 0.687021 Entmake: 0.078012 VLA1: 0.15598387 VLA2: 0.12500435 Command: 0.703034 Entmake: 0.063005 VLA1: 0.15598387 VLA2: 0.14097691 Quote
Lee Mac Posted March 9, 2010 Author Posted March 9, 2010 I never realised that vlax-invoke/get were quicker than the equivalent methods... Quote
devitg Posted March 9, 2010 Posted March 9, 2010 IMO, some things are easier in Vanilla LISP, and some easier in Visual. Hi , I agree. I use both . Quote
naruse107 Posted May 12, 2019 Posted May 12, 2019 On 2/13/2010 at 1:27 AM, Lee Mac said: Just posted this over at theSwamp, thought I'd share it with you fine people also. I was inspired to write a few functions that will generate entities using the minimum possible data requirements - hence all other values are taken as default. This is handy for those who want to quickly generate entities without having to look up what codes are necessary, and which are surplus to requirement. Also, it helps beginners to use the entmake function in their codes, without too much effort. These, of course, are the quickest way to generate entities in AutoCAD - quicker than VL, and much quicker than a command call. Also, they are not affected by OSnap (so no need to turn it off). Example of usage, to create a line from (0,0,0) to (1,0,0): (Line '(0 0 0) '(1 0 0)) Yes, its as easy as that. The functions will also return the entity name of the newly created entity (if successful), and so, no need to be using 'entlast'... If you have any queries as to how to use them, just ask. (defun 3DFace (p1 p2 p3 p4) (entmakex (list (cons 0 "3DFACE") (cons 10 p1) (cons 11 p2) (cons 12 p3) (cons 13 p4)))) (defun Arc (cen rad sAng eAng) (entmakex (list (cons 0 "ARC") (cons 10 cen) (cons 40 rad) (cons 50 sAng) (cons 51 eAng)))) (defun AttDef (tag prmpt def pt hgt flag) (entmakex (list (cons 0 "ATTDEF") (cons 10 pt) (cons 40 hgt) (cons 1 def) (cons 3 prmpt) (cons 2 tag) (cons 70 flag)))) (defun Circle (cen rad) (entmakex (list (cons 0 "CIRCLE") (cons 10 cen) (cons 40 rad)))) (defun Ellipse (cen maj ratio) (entmakex (list (cons 0 "ELLIPSE") (cons 100 "AcDbEntity") (cons 100 "AcDbEllipse") (cons 10 cen) (cons 11 maj) (cons 40 ratio) (cons 41 0) (cons 42 (* 2 pi))))) (defun Insert (pt Nme) (entmakex (list (cons 0 "INSERT") (cons 2 Nme) (cons 10 pt)))) (defun Line (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)))) (defun LWPoly (lst cls) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls)) (mapcar (function (lambda (p) (cons 10 p))) lst)))) (defun M-Text (pt str) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 pt) (cons 1 str)))) (defun Point (pt) (entmakex (list (cons 0 "POINT") (cons 10 pt)))) (defun Polyline (lst) (entmakex (list (cons 0 "POLYLINE") (cons 10 '(0 0 0)))) (mapcar (function (lambda (p) (entmake (list (cons 0 "VERTEX") (cons 10 p))))) lst) (entmakex (list (cons 0 "SEQEND")))) (defun Solid (p1 p2 p3 p4) (entmakex (list (cons 0 "SOLID") (cons 10 p1) (cons 11 p2) (cons 12 p3) (cons 13 p4)))) (defun Text (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 1 str)))) (defun Trce (p1 p2 p3 p4) (entmakex (list (cons 0 "TRACE") (cons 10 p1) (cons 11 p2) (cons 12 p3) (cons 13 p4)))) (defun xLine (pt vec) (entmakex (list (cons 0 "XLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbXline") (cons 10 pt) (cons 11 vec)))) (defun Layer (Nme) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 Nme) (cons 70 0)))) (defun Layer (Nme Col Ltyp LWgt Plt) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 Nme) (cons 70 0) (cons 62 Col) (cons 6 Ltyp) (cons 290 Plt) (cons 370 LWgt)))) The list is a working progress of course, but this is what I have so far. Also, if the argument names aren't too clear, a reference as to what they mean can be found here. Lee Thanks Lee, I have 1 problem, how do i inserting blocks with different attribute using your function thanks for help naruse Quote
BIGAL Posted May 12, 2019 Posted May 12, 2019 Answer may be here need to scroll down the big code. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/entmake-vs-insert-command/td-p/3162178 Ps took about 1 minute find just googled. entmake insert block Quote
Lee Mac Posted May 13, 2019 Author Posted May 13, 2019 23 hours ago, naruse107 said: I have 1 problem, how do i inserting blocks with different attribute using your function Whilst it is certainly possible to insert an attributed block reference using entmake, you first have to entmake the block reference (INSERT entity), and then entmake each attribute reference (ATTRIB entity) transforming the position/scale/rotation/orientation of the attribute definitions within the block definition relative to the position/scale/rotation/orientation of the block reference, and finally entmake the terminating SEQEND entity. An example of this procedure may be found here. However, for an attributed block, it is far easier to use the ActiveX insertblock method which will automatically generate the attribute references when inserting the block reference. Similarly, when rotating an attributed block reference, if you simply modify the value associated with DXF group 50, you will rotate the block reference independently of its attribute references; whereas using the ActiveX rotate method will rotate the attributed block reference as a single object. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.