Jump to content

Leaderboard

  1. Lee Mac

    Lee Mac

    Trusted Members


    • Points

      36

    • Content Count

      19,938


  2. ronjonp

    ronjonp

    Trusted Members


    • Points

      17

    • Content Count

      1,129


  3. Tharwat

    Tharwat

    Trusted Members


    • Points

      10

    • Content Count

      6,508


  4. BIGAL

    BIGAL

    Trusted Members


    • Points

      9

    • Content Count

      10,889



Popular Content

Showing content with the highest reputation since 12/22/2018 in all areas

  1. 3 points
    Hi Tony, Don't get me wrong, but you don't seem to have enough experience. Where experience != knowledge. Judging by your requests from your posts, all of them can be done with AutoLISP. Here are two examples to create a simple line - AutoLISP : (setq p1 '(5. 5. 0)) (setq p2 '(12. 3. 0.)) (entmakex (cons '(0 . "LINE") (mapcar 'cons '(10 11) (list p1 p2)))) C# (.NET) /source/ : using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Geometry; [CommandMethod("AddLine")] public static void AddLine() { // Get the current document and database Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; // Start a transaction using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { // Open the Block table for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // Create a line that starts at 5,5 and ends at 12,3 using (Line acLine = new Line(new Point3d(5, 5, 0), new Point3d(12, 3, 0))) { // Add the new object to the block table record and the transaction acBlkTblRec.AppendEntity(acLine); acTrans.AddNewlyCreatedDBObject(acLine, true); } // Save the new object to the database acTrans.Commit(); } } Its true that AutoLISP is limited (although I don't know by how much and at which aspects), but as you can see its alot simplier to use, shorter and easier to maintain. I only know one huge drawback that is within the DCL dialogs (not enough event handlers for the tiles/controls.. like mouse_hover / mouse_leave ), so you can't be that fancy in there. But as long you get the job done, who cares ? I have this real-life friend that brags about learning the powerful language C#, but also null experience (and doesn't seem that he's about to sit and write some actual code). So when I ask, Q: Ok so what you are able to do with it? A: IDK, but I've heard many things can be done in C# Q: Check out this TicTacToe code I wrote in C# A: Sorry, but I don't understand it and I get lost at it (reason is because when one doesn't practice, isn't able to follow any code's algorithm) So the answer is short - open up that Notepad++/VLIDE/Visual Studio and start to practice, so you'll build your own opinion (and it will change quite few times).
  2. 2 points
    If you use layouts each dwg would be at real scale as the layout view would be scaled, the title block being in the layout is at 1:1 scale, so no factor required.
  3. 2 points
    This is one particular task where the individual ActiveX properties accessible through Visual LISP are a huge advantage... Consider the following toggle implemented in Visual LISP: (defun c:txtin-visual ( / i o s ) (if (setq s (ssget "_:L" '((0 . "*DIMENSION")))) (repeat (setq i (sslength s)) (setq i (1- i) o (vlax-ename->vla-object (ssname s i)) ) (vlax-put o 'textinside (~ (vlax-get o 'textinside))) ) ) (princ) ) (vl-load-com) (princ) Compared with the corresponding Vanilla AutoLISP solution: (defun c:txtin-vanilla ( / a b e i s x ) (if (setq s (ssget "_:L" '((0 . "*DIMENSION")))) (progn (regapp "ACAD") (repeat (setq i (sslength s)) (setq i (1- i) e (ssname s i) ) (cond ( (not (and (setq x (cdadr (assoc -3 (entget e '("ACAD"))))) (setq a (cdr (member '(1000 . "DSTYLE") x))) ) ) (setq x (append x '( (1000 . "DSTYLE") (1002 . "{") (1070 . 174) (1070 . 001) (1002 . "}") ) ) ) ) ( (not (setq b (cdr (member '(1070 . 174) a)))) (setq x (append (reverse (member '(1000 . "DSTYLE") (reverse x))) '( (1002 . "{") (1070 . 174) (1070 . 001) ) (cdr a) ) ) ) ( (setq x (append (reverse (member '(1000 . "DSTYLE") (reverse x))) (reverse (member '(1070 . 174) (reverse a))) (cons (cons 1070 (- 1 (cdr (assoc 1070 b)))) (cdr b)) ) ) ) ) (entmod (append (entget e) (list (list -3 (cons "ACAD" x))))) ) ) ) (princ) )
  4. 2 points
    Glad to help .. I used the VLIDE to find it: VLA-PUT-TEXT then CNTRL+SHIFT+A or CNTRL+SHIFT+SPACE
  5. 2 points
    Thanks rkmcswain, I ended up using Notepad++ to strip the colour tags, as suggested in that post you linked. Find and replace the following, using REGEX mode, for anyone interested: \[.+?\]
  6. 2 points
    As an example, consider the following: (defun c:test ( / *error* dcl dch des ) (defun *error* ( msg ) (if (< 0 dch) (unload_dialog dch)) (if (= 'file (type des)) (close des)) (if (and (= 'str (type dcl)) (setq dcl (findfile dcl))) (vl-file-delete dcl)) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (if (and (setq dcl (vl-filename-mktemp nil nil ".dcl")) (setq des (open dcl "w")) (foreach str '( "butt : button" "{" " width = 15;" " height = 2;" " fixed_width = true;" " fixed_height = true;" " alignment = centered;" "}" "test : dialog" "{" " label = \"Example 1\";" " spacer_1;" " : row" " {" " : butt { key = \"b1\"; label = \"Button 1\"; }" " : butt { key = \"b2\"; label = \"Button 2\"; }" " : butt { key = \"b3\"; label = \"Button 3\"; is_cancel = true; }" " }" " spacer;" " : butt" " {" " label = \"OK\";" " key = \"accept\";" " is_default = true;" " }" " spacer;" "}" ) (write-line str des) ) (not (setq des (close des))) (< 0 (setq dch (load_dialog dcl))) (new_dialog "test" dch) ) (progn (action_tile "b1" "(alert \"I am button 1.\")") (action_tile "b2" "(alert \"I am button 2.\")") (action_tile "b3" "(alert \"I am button 3.\nI am also cancel.\") (done_dialog 0)") (start_dialog) ) ) (*error* nil) (princ) ) Observe that the action of clicking the red "x" in the corner of the window has the same effect as clicking "Button 3" since this tile has the is_cancel = true attribute.
  7. 2 points
    Good explanations indeed Grrr. The following attribute could also be used in lieu of that if statement. allow_accept = true;
  8. 2 points
    If you a re talking strictly AutoCAD based programming languages: Common lisp is one the oldest languages a round AutoLSP (AutoCADs version of common LISP) has been around 25+ years. It is not going anywhere unless AutoDESK looses a few more brain cells. Bricscad is doing a nice job of developing their lisp interface Visual LSP is going on 15-20 years and has some enhanced functions and like Vanilla AutoLISP, it is no addtional cost incorporated into plain AutoCAD I thought VB had been abandoned a good while ago as a legacy language Vanilla AutoLISP in conjunction with DOSLIB functions can preform the vast majority of customization needs that I see requests for. It's more about programmer's skills and knowledge than the language's limitations Various languages can be compiled to run in AutoCAD as EXE EXP ARX but they are VERY complex and historically have had to been recompiled regularly HTML5 may 1 day be thing . Who knows ! C+ F Maybe ! My advice is to learn and be proficient in a simple language . And then try an advanced 1 if you need to. -David
  9. 1 point
    There is no way of specifying a random selection, since items are stored sequentially in the drawing database. You either need to selected multiple entities, generate a random integer and then access that item in the selection set or you become the random select mode using "ssget" in single select mode. If the latter and assuming you are talking about LWPolylines, try the following lisp (defun c:testzw ( / ss ll ur) ;define local variables (setq ss (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE") (70 . 1) (60 . 0)))) (vla-getboundingbox (vlax-ename->vla-object (ssname ss 0)) 'll 'ur) (vla-zoomwindow (vlax-get-acad-object) ll ur) );end_defun Explanation of above code. If using the above the (60 . 0) isn't really useful as you can't select an invisible object, but it is useful when using ssget with "_X" since this gets all objects in the database ; This selects all closed (70 . 1) visible (60 . 0) LWPolylines in the drawing. The filter is a quoted list of dxf dotted pairs (setq ss (ssget "_X" '((0 . "LWPOLYLINE") (70 . 1) (60 . 0)))) ; This is single entity selection mode (simulates entsel) excluding objects on locked layers (:L) Filter as above (setq ss (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE") (70 . 1) (60 . 0)))) ; Should you want to include a layer to further filter the list (setq ss (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE") (8 . "LAYERNAME") (70 . 1) (60 . 0)))) ; In single selection mode this will get the single entity in the selection set (ssname ss 0) and converts it to a vla-object ; and then get the extents (boundingbox) of the object, returning the two points as variants into the specified ; variables (ll and ur). Note that the variable names are quoted, and should be defined in any lisp as unquoted ; local variable so they can be converted or used later (vla-getboundingbox (vlax-ename->vla-object (ssname ss 0)) 'll 'ur) ; This uses the variables from above (without extracting the values) and plugs them straight into the visual lisp ; zoomwindow method, since this requires two points as variants. It is therefore uneconomical to convert them to coord list and back again (vla-ZoomWindow (vlax-get-acad-object) ll ur)
  10. 1 point
    Hi David, I can find them, but wouln't have a clue what to do then, a search for site:www.cadtutor.net [/color] throws up 19 pages of results, which would keep you busy for a while and I'm not sure that would cover all the problems
  11. 1 point
  12. 1 point
  13. 1 point
    An excellent idea Grrr! I have now updated the utility to achieve exactly that - I've also rewritten it to handle the various data types more elegantly - thank you for this suggestion.
  14. 1 point
    You're most welcome @amir0914 - You may find my Dump Object utility useful in this regard - it's a simple program and merely a wrapper for the vlax-dump-object function to allow you to select a primary or nested object.
  15. 1 point
    I think you're missing a few closing parenthesis
  16. 1 point
    A VLA Layer object does not have a count property - you can check the available properties & methods for an object using the vlax-dump-object function.
  17. 1 point
    Hi, A good practice is to write the DCL code inside of the temporary file as multiple lines, then it would be easier to determine the error, so instead of (write-line (strcat "string1" "string2" ... "stringN") file) Use: (foreach line (list "string1" "string2" ... "stringN") (write-line line file) ) In your code it would look like: (foreach line '("senha : dialog" "{ label = \"Senha\"; key = \"efernal\"; initial_focus = \"senha\"; width = 40; fixed_width = true;" " : spacer{ height = 0.5; }" " : text" " { label = \"Entre com a senha, por favor!\";" " alignment = centered;" " fixed_width = true;" " }" " : spacer { height=0.5; }" " : edit_box" " {" " key = \"senha\";" " width = 30;" " edit_width = 30;" " edit_limit = 25;" " alignment = centered;" " fixed_width = true;" " password_char = \"*\";" " }" " : spacer { height=0.5; }" " : button" " {" " label = \"Prosseguir\";" " key = \"accept\";" " is_default = true;" " width = 16;" " height = 2.5;" " fixed_width = true;" " fixed_height = true;" " alignment = centered;" " }" " : spacer { height = 0.5; }" "}" ); list (write-line line file) ); foreach In your case, you had a redundant bracket on the right: "fixed_width=true;""fixed_height=true;""alignment=centered;" "}"":spacer{height=0.5;}" "}}" ; <<<<<--- This one ) file ) (close file) You wouldn't have done this mistake if you used a proper indentation, so the "containers" that define the tile's properties could be distinct with a naked eye. And suggestion for improvement.. well if you see yourself as a user, the obvious thing would be right after you type the password is to hit enter key, in order to attempt to login. This can be done with checking the callback reason of the edit_box tile, so with: (action_tile "senha" "(setq senha $value)(alert (vl-prin1-to-string $reason))") When you type something and hit [ENTER] you w'll be alerted with a value of 1 Then lets make, when you hit enter within the edit_box, just to exit the dialog and continue checking our input: (action_tile "senha" "(setq senha $value)(if (= 1 $reason) (done_dialog 1))") Another thoughts.. (maybe you'll solve them, maybe someone will help you here) What if the user accidentally invoked this command "Senha"" ? wouldn't you let him to cancel the dialog ? In your case you'll force him to trigger an error in the program with ESC key, but then what would happen to the Tmp.dcl file ? Would you check for an obviously wrong password like four spaces " " or an empty string "" ?
  18. 1 point
    How about write-char? p/s : FYI I've seen software similar @Tharwat's split method to convert string to (eg: com port devices) '*.raw' format which string data was 'chopped' to an 8bit-block (128 ascii char for each line) with bcc checksum
  19. 1 point
    The following program will allow you to specify either a block name, attribute tag, or attribute value (or all three), and will return a selection of all blocks matching the given criteria, residing in the current layout: ;; Block Selection - Lee Mac ;; Selects all blocks in the current layout with a given block name or which contain a specified attribute tag and/or value. (defun c:bsel ( / att atx blk cnt ent enx flg idx sel str tag ) (setq blk (strcase (getstring t "\nSpecify block name <any>: ")) tag (strcase (getstring "\nSpecify attribute tag <any>: ")) str (strcase (getstring t (strcat "\nSpecify attribute value" (if (= "" tag blk) ": " " <any>: ")))) ) (if (not (= "" str tag blk)) (if (and (setq sel (ssget "_X" (append '((000 . "INSERT")) (if (not (= "" tag str)) '((066 . 1))) (if (/= "" blk) (list (cons 2 (strcat "`*U*," blk)))) (if (= 1 (getvar 'cvport)) (list (cons 410 (getvar 'ctab))) '((410 . "Model")) ) ) ) ) (progn (repeat (setq idx (sslength sel)) (setq ent (ssname sel (setq idx (1- idx))) enx (entget ent) ) (cond ( (not (or (= "" blk) (wcmatch (strcase (LM:name->effectivename (cdr (assoc 2 enx)))) blk))) (ssdel ent sel) ) ( (member (cdr (assoc 66 enx)) '(nil 0))) ( (progn (setq att (entnext ent) atx (entget att) flg nil ) (while (and (= "ATTRIB" (cdr (assoc 0 atx))) (not (and (or (= "" str) (wcmatch (strcase (cdr (assoc 1 atx))) str)) (or (= "" tag) (wcmatch (strcase (cdr (assoc 2 atx))) tag)) ) ) ) (setq att (entnext att) atx (entget att) ) ) (= "SEQEND" (cdr (assoc 0 atx))) ) (ssdel ent sel) ) ) ) (< 0 (setq cnt (sslength sel))) ) ) (progn (princ (strcat "\n" (itoa cnt) " block" (if (= 1 cnt) "" "s") " found.")) (sssetfirst nil sel) ) (princ "\nNo blocks found.") ) ) (princ) ) ;; Block Name -> Effective Block Name - Lee Mac ;; blk - [str] Block name (defun LM:name->effectivename ( blk / rep ) (if (and (wcmatch blk "`**") (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk)))) '("acdbblockrepbtag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (cdr (assoc 2 (entget rep))) blk ) ) (princ)
  20. 1 point
    You want to know how to learn AutoCAD? There are many ways. You could... 1. Self learn using a good AutoCAD aftermarket book such as those written by George Omura. 2. Self learn by signing up for online tutorials at Lynda.com. 3. Self learn by utilizing the free AutoCAD tutorials at MyCadSite.com. 4. Find a mentor. 5. Sign up for a basic AutoCAD class at an Authorized AutoCAD Reseller. 6. Sign up for a basic AutoCAD class either at a local community college or an adult education center. 7. Purchase basic and advanced AutCAD training CD's or DVD's. These are some of the options available to you. Select one that fits your budget and lifestyle then go for it. Good luck in your endeavors.
  21. 1 point
    Find a set of tutorials you like and go through them. Different people learn in different ways, so you'll have to try a few to get the best fit. The same applies to books, if you're into print. For reference, Autodesk has a Knowledge Base. It's their product, who better to turn to? Nobody can remember every option for every command, and I'm still finding obscure, useful stuff after 25 years. As always, the best way to learn is to practice. Don't be afraid to make mistakes, you can always bail out of a drawing and start over.
  22. 1 point
    Hi all,i have a lisp which can get the piling as built deviation but need to click one by one. 1.Click the proposed position 2.Click the as built pile position 3.Place the deviation (This is what i do so far) I wonder any lisp which can get the piling as built deviation automatic ?because i alway need to click the piling point (as built) for not less than 600 pile:( attach here with example drawing which i have done Hope my question not sound crazy:oops: or i expect too much which lisp can do. Example piling as built.dwg
  23. 1 point
    javid, here is a very basic version for you to try. It will only insert the block if it already exists in the drawing (defun c:blockmp (/ blknme p1 p2 ang) (setq blknme "Name of block") ;Name of the block (setq p1 (getpoint "\nPick first point: ")) (setq p2 (getpoint p1 "\nPick second point: ")) (setq ang (angtos (angle p1 p2))) ;Calculates the angle between points one and two (command "_Insert" blknme "_mtp" p1 p2 1 "" ang) )
  24. 1 point
    Hi, the lisp, anticipated with two images here and here, aligns between two curves the hatch elements and creates a block containing the lines of the new geometry. The original shape of the hatch shall be a rectangle, an isosceles triangle or an isosceles trapezoid. In case of large hatches is recommended to divide it into portions, any case it is better to try with small hatches to verify the time required for processing, in according to PC performances, too. Not all hatches are suitable for processing. I hope it works well and there are no problems. AlignH.lsp
  25. 1 point
    you have found one way to update blocks. I don't use design centre but I think what you have suggested is correct. As for adding attributes to existing blocks you have to "sync" the existing block entries to the modified ones. Either use BATTMAN or ATTSYNC to do this.
  • Newsletter

    Want to keep up to date with all our latest news and information?

    Sign Up
×