Michaels Posted July 10, 2010 Posted July 10, 2010 Hello everybody. This is my first post in this wonderful Forum and I hope that I would be welcomed in this precious Forum. I Know how to deal with Autolisp, But not that much so I am in need of Mline lisp using Entmake with round corners and close sides, Is this possible .... ?? Many Thanks Michaels. Quote
Lee Mac Posted July 10, 2010 Posted July 10, 2010 Entmake 'ing an MLine is very troublesome and will cause exceptions - you can entmake the MLineStyle, but the MLine object itself is better created using ActiveX methods. Here are a few example functions: ;;-------------------=={ Add MLine Style }==------------------;; ;; ;; ;; Adds an MLine Style to the ACAD_MLINESTYLE dictionary ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; data - a DXF list of MLineStyle data ;; ;;------------------------------------------------------------;; ;; Returns: MLineStyle Dictionary Entity, else nil ;; ;;------------------------------------------------------------;; (defun LM:AddMLineStyle ( data / dic obj ) ;; © Lee Mac 2010 (if (and (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE")) (not (dictsearch (setq dic (cdr (assoc -1 dic))) (cdr (assoc 2 data)))) (setq obj (entmakex data))) (dictadd dic (cdr (assoc 2 data)) obj) ) ) ;;-----------------=={ Delete MLine Style }==-----------------;; ;; ;; ;; Removes an MLine Style from the ACAD_MLINESTYLE ;; ;; dictionary ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; name - the name of an MLine Style to remove ;; ;;------------------------------------------------------------;; ;; Returns: Entity name of removed style, else nil ;; ;;------------------------------------------------------------;; (defun LM:DeleteMLineStyle ( name / dic ) ;; © Lee Mac 2010 (if (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE")) (dictremove (cdr (assoc -1 dic)) name) ) ) ;;------------------------------------------------------------;; ;; Test Function (defun Example ( / lst ) (setq lst (list (cons 0 "MLINESTYLE") (cons 100 "AcDbMlineStyle") (cons 2 "Example") ; Name (cons 70 (+ 272)) ; caps/fill/joints (cons 3 "") ; Desc (cons 51 (/ pi 2.)); Start ang (cons 52 (/ pi 2.)); End ang (cons 71 2) ; Number of lines (cons 49 -0.5) ; Element Offset (cons 62 256) ; Element Colour (cons 6 "BYLAYER") ; Element Linetype (cons 49 0.5) (cons 62 256) (cons 6 "BYLAYER") ) ) (LM:AddMLineStyle lst) ) ;;----------------------=={ Add MLine }==---------------------;; ;; ;; ;; Adds a VLA MLine Object to the supplied Block container ;; ;; object, going through the supplied vertex list. ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; space - VLA Block Object ;; ;; ptLst - List of 3D Points for MLine Vertices ;; ;;------------------------------------------------------------;; ;; Returns: VLA MLine Object, else nil ;; ;;------------------------------------------------------------;; (defun LM:AddMLine ( space ptLst ) ;; © Lee Mac 2010 (vla-AddMline space (LM:PointVariant ptLst)) ) ;;------------------=={ Safearray Variant }==-----------------;; ;; ;; ;; Creates a populated Safearray Variant of a specified ;; ;; data type ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; datatype - variant type enum (eg vlax-vbDouble) ;; ;; data - list of static type data ;; ;;------------------------------------------------------------;; ;; Returns: VLA Variant Object of type specified ;; ;;------------------------------------------------------------;; (defun LM:SafearrayVariant ( datatype data ) ;; © Lee Mac 2010 (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray datatype (cons 0 (1- (length data))) ) data ) ) ) ;;--------------------=={ Point Variant }==-------------------;; ;; ;; ;; Creates a populated Safearray Variant of Double type. ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; lst - list of 2D/3D Points to populate the Variant. ;; ;;------------------------------------------------------------;; ;; Returns: VLA Safearray Variant ;; ;;------------------------------------------------------------;; (defun LM:PointVariant ( lst ) ;; © Lee Mac 2010 (LM:SafearrayVariant vlax-VBDouble (apply 'append lst)) ) ;;---------------------=={ Get Points }==---------------------;; ;; ;; ;; Returns a list of selected points. ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: - None - ;; ;;------------------------------------------------------------;; ;; Returns: List of 3D Points ;; ;;------------------------------------------------------------;; (defun LM:GetPoints ( / lst pt ) ;; © Lee Mac 2010 (if (car (setq lst (list (getpoint "\nPick First Point: ")))) (while (setq pt (getpoint "\nPick Next Point: " (car lst))) (mapcar (function (lambda ( from to ) (grdraw from to 3 1)) ) (cdr (reverse (setq lst (cons pt lst)))) (reverse (cdr lst)) ) ) ) (redraw) (reverse lst) ) ;;------------------------------------------------------------;; ;; Test Function (defun c:test ( / lst ) (if (setq lst (LM:GetPoints)) (LM:AddMLine (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object) ) ) lst ) ) ) IMO, for visual effect and ease of use - just use (command "_.mline") in this case. Quote
Michaels Posted July 10, 2010 Author Posted July 10, 2010 Thank you. It is running up to last point and at the end error and with nothing drawn. Error message in command line . ; error: no function definition: VLAX-GET-ACAD-OBJECT The program running as a transparent green line only. Any solution. michaels Quote
The Buzzard Posted July 10, 2010 Posted July 10, 2010 Thank you. It is running up to last point and at the end error and with nothing drawn. Error message in command line . ; error: no function definition: VLAX-GET-ACAD-OBJECT The program running as a transparent green line only. Any solution. michaels I find that it draws the mline to each point ok, But leaves this message at the end. # Try adding VL-LOAD-COM , I useally keep this in my acaddoc.lsp (defun c:test ( / lst ) [color=red](vl-load-com)[/color] Loads Visual LISP extensions to AutoLISP (vl-load-com) This function loads the extended AutoLISP functions provided with Visual LISP. The Visual LISP extensions implement ActiveX and AutoCAD reactor support through AutoLISP, and also provide ActiveX utility and data conversion functions, dictionary handling functions, and curve measurement functions. If the extensions are already loaded, [i]vl-load-com[/i] does nothing. Return Values Unspecified. It will still leave the message I mentioned, But will draw the mline. Lee would have an answer to this. Quote
Michaels Posted July 10, 2010 Author Posted July 10, 2010 Thanks The buzzard But nothing has changed at all. Any other soultion ??? Regards Michaels Quote
The Buzzard Posted July 10, 2010 Posted July 10, 2010 Thanks The buzzard But nothing has changed at all. Any other soultion ??? Regards Michaels Make sure you saved the change in the lisp. Also start a new drawing session and then load the lisp again. Start the lisp and off you go. Give it another try. Quote
Michaels Posted July 10, 2010 Author Posted July 10, 2010 Yahaa That's right. I used to load codes from Visual Lisp editor directly, But to save it as a lisp file and load it once again is different and better. So the Mline drawn, But as you have eariler mentioned, the code appear at the end. #<VLA-OBJECT IAcadMLine 0cc48984> What does it mean .... ???? Thanks Michaels Quote
The Buzzard Posted July 10, 2010 Posted July 10, 2010 Yahaa That's right. I used to load codes from Visual Lisp editor directly, But to save it as a lisp file and load it once again is different and better. So the Mline drawn, But as you have eariler mentioned, the code appear at the end. #<VLA-OBJECT IAcadMLine 0cc48984> What does it mean .... ???? Thanks Michaels I am not sure. As I said, Lee would have an answer to that one. But I am sure the code will give you some idea how to make your own and you can figure out how to modify it to your liking. I beleive that this is the first code I have seen for mline and I find it very interesting. Quote
spicelook123 Posted July 10, 2010 Posted July 10, 2010 hi all i am doing small project in land desktop2002, clint provied jpeg&jgw files to convert to plines. pls tell me any simple way to connvert Quote
The Buzzard Posted July 10, 2010 Posted July 10, 2010 hi alli am doing small project in land desktop2002, clint provied jpeg&jgw files to convert to plines. pls tell me any simple way to connvert Welcome to the forum, I suggest you start a new thread. You will get more answers. Your subject has nothing to do with this thread. Good Luck Quote
Kerry Brown Posted July 10, 2010 Posted July 10, 2010 Yahaa That's right. I used to load codes from Visual Lisp editor directly, But to save it as a lisp file and load it once again is different and better. So the Mline drawn, But as you have eariler mentioned, the code appear at the end. #<VLA-OBJECT IAcadMLine 0cc48984> What does it mean .... ???? Thanks Michaels That is the ActiveX ID for the MLine object created. Sometimes functions are designed to return the result of the last evaluated statement .... this is that result. If you don't need the return value just add (princ) as the last statement in the command you called. Quote
The Buzzard Posted July 10, 2010 Posted July 10, 2010 That is the ActiveX ID for the MLine object created.Sometimes functions are designed to return the result of the last evaluated statement .... this is that result. If you don't need the return value just add (princ) as the last statement in the command you called. Thanks Kerry Quote
The Buzzard Posted July 11, 2010 Posted July 11, 2010 Read the code headers for function returns. So you can add on to this lisp using the result of that statement. Thanks Lee Quote
Lee Mac Posted July 11, 2010 Posted July 11, 2010 This isn't a program. Rather I have provided library functions which should not be (or need to be) modified. They should be called by a program and the returns of such a call can then be manipulated. I include a couple of test functions to merely demonstrate their use. I would repeat - this is not intended to be a complete program. Quote
The Buzzard Posted July 11, 2010 Posted July 11, 2010 This isn't a program. Rather I have provided library functions which should not be (or need to be) modified. They should be called by a program and the returns of such a call can then be manipulated. I include a couple of test functions to merely demonstrate their use. I would repeat - this is not intended to be a complete program. I was just looking that over and got a bit puzzled. Now I do not have to ask you a dumb question. I rememeber back a while when you did the entmake thread with examples and you left mline out. I knew you would get to it sooner or later. Lots of great stuff here Lee. Again Thanks 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.