Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/15/2022 in all areas

  1. Nicely done 1 step missing "MED AUX" is desired tab, as its opening an existing file the tab will exist or not so needs to be added. This is some examples that may be useful. I have my own version of a excel lisp with lots of defuns, started with getexcel.lsp. Just use the correct defuns. ; set current worksheet (defun setsheet ( sheetname / ) (setq xlSheets (vl-catch-all-apply 'vlax-get-property (list myxl "Worksheets"))) (setq curSheet (vl-catch-all-apply 'vlax-get-property (list xlSheets "Item" sheetname))) (vlax-invoke-method curSheet "Activate") ) ; add a sheetName by FIXO no longer with us (defun addsheet (NewSheetName / ) (setq xlSheets (vlax-get-property myBook "Sheets")) ;; add new sheet (vlax-invoke-method xlsheets 'Add nil nil nil) ;; get the number of sheets (setq xlCount (vlax-get-property xlSheets 'Count)) ;; get the newly created sheet (setq xlSheet (vlax-get-property xlSheets "Item" (vlax-get-property (vlax-get-property myXL 'ActiveSheet) 'Name))) ;; change name of sheet to what you need (vlax-put-property xlSheet 'Name NewSheetName) ;; move sheet to the end of book (vlax-invoke-method xlSheet 'Move (vlax-get-property xlSheets "Item" (vlax-get-property xlSheets 'Count))) )
    3 points
  2. Working through what you have made up and with a similar idea to MHUPP, above, create a selection set from the temporary lines and delete these. I did my version with a loop to create each temporary line and add them to the set as you go, MHUPP did all the lines and then creates the selection set - same result though. I suspect mine will be slower if there are a lot of lines (but only by fractions of a second). ;;https://www.cadtutor.net/forum/topic/21484-i-search-for-offset-with-same-value-and-opposite-direction/#comment-175406 (defun c:APV ( / TargEnt TargLayer MySS of MyOffSS) ;;Errors (defun *error* ( msg ) (and undo (vla-EndUndomark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (princ) ) ;; Set variables (setq MyOffSS (ssadd)) ;; Loop layers selection (while ; while a ;;Select Layer (setq TargEnt (car (entsel "\nSelect object on layer to select: "))) (setq TargLayer (assoc 8 (entget TargEnt))) (setq MySS (ssget "_X" (list TargLayer (cons 0 "ARC,CIRCLE,ELLIPSE,*LINE") ) )) ;;Get Offset (setq of (getdist "\nSpecify Offset Distance: ")) ;; Do Offset ;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/vla-offset-directions/td-p/1705849 (setq acount 0) (while (< acount (sslength MySS)) ; while b (setq VlaOb (vlax-ename->vla-object (ssname MySS acount))) (vla-offset VlaOb of ) ;; offset line 1 (setq MyOffSS (ssadd (entlast) MyOffSS)) ;; add offset to selection set (vla-offset VlaOb (* of -1) ) ;; offset line 2 (setq MyOffSS (ssadd (entlast) MyOffSS)) ;; add offset to selection set (setq acount (+ acount 1)) ) ; end while b ) ; end while a (while (setq pt (getpoint "\nPick internal point: ")) ; while c (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "") ) ; end while c ;; Delete temporary Lines (command "_.erase" MyOffSS "") ;; Delete selection set ;;Finish (setq undo (vla-EndUndoMark doc)) (princ) ) I have added a couple of links to the code above just to give credit where it is due (I think your code was mostly copied from the link at the top?)
    2 points
  3. Use <> when posting code so it looks like this. Using (entlast) to group up offset entity's so they can be deleted later. (defun c:APV (/ doc SS1 TargLayer SS of undo obj pt) (defun *error* (msg) (and undo (vla-EndUndomark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (princ) ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-StartUndomark doc) (setq SS1 (ssadd)) ;add empty selection set to add entity's too (setq LastEnt (entlast)) ;set last entity before creating objects (while (setq TargEnt (car (entsel "\nSelect Object(s): "))) (setq TargLayer (cdr (assoc 8 (entget TargEnt)))) (if (and (setq ss (ssget "_X" (list '(0 . "ARC,CIRCLE,ELLIPSE,*LINE") (cons 8 TargLayer)))) (setq of (getdist "\nSpecify Offset Distance: ")) ) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-offset (setq obj (vlax-ename->vla-object ent)) of) (vla-offset obj (- of)) (vla-delete obj) ) ) (if (setq en (entnext LastEnt)) ;adds all offsets to SS1 (while en (ssadd en SS1) (setq en (entnext en)) ) ) ) (while (setq pt (getpoint "\nPick internal point: ")) ;(vl-cmdf "_.Boundary" "_non" pt "") (command "_.Boundary" "_A" "_I" "_N" "" "" "_non" pt "") ;doesn't work with BircsCAD ) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS1))) (entdel ent) ;Deletes all offset entity's ) ;(command "_.Erase" SS "") ;another way to do it all at once. (vla-EndUndoMark doc) (princ) ) Don't really like this lisp because its selecting alot of things based on a entsel's layer and deleting them. Has a great potential of deleting things you want to keep and/or things on a different tab. Should really only select the things you want to offset to create the boundary.
    2 points
  4. Refer to this - selection boolean functions: http://www.theswamp.org/index.php?topic=46652.msg516656#msg516656 Another Example: http://www.theswamp.org/index.php?topic=48591.msg536882#msg536882
    2 points
  5. I oped to use foreach because Its cleaner. but for clarity this is what was happening. The repeat method wasn't working because its was always checking (ssname mylist 0). So once it finds an entity that's not a member of oldlist it breaks and stops checking the rest of the entity's. If you have 5 entity's in mylist they number 0 1 2 3 4 Repeat first run checks entity 0 its in oldlist so its removed now the rest of the entity's drop down a # to 0 1 2 3 Repeat runs a second time checking entity 0 (that was previously entity 1) its not in oldlist so its not removed and nothing changes Repeat will run the same check on entity 0 and nothing changes it will keep doing this until loop is done. So what needs to happen is if memeber remove from list if not add +1 to "a" so it skips that entity the next loop. (defun c:test () (setq mylist (ssget)) (setq oldlist (ssget)) (setq a 0) (repeat (sslength mylist) (setq ent (ssname mylist a)) (if (ssmemb ent oldlist) (ssdel ent mylist) (setq a (1+ a)) ) ) (sssetfirst nil mylist) (princ) ) Also don't need (progn after if unless you want to run multiple lines of code.
    2 points
  6. command WBLOCK does that. Or do you need LISP to do anything extra?
    2 points
  7. You can use a ssget and pick just one object, then use ssname ss 0 to get that entity, the advantage is that you can use a filter of "*TEXT,INSERT" so can only be an object of that type. Check out Lee-mac ssget, ssget Function Reference | Lee Mac Programming (lee-mac.com) http://lee-mac.com/ssget.html (ssget "_+.:E:S" '((0 . "*TEXT,INSERT"))) A dwg would help. Your mixing VL and assoc maybe just use the VL methods. Getattributes comes to mind.
    1 point
  8. Thank you for the explanation and examples.
    1 point
  9. yes it works now , thank you very much for your great helps @Steven P @BIGAL and all .
    1 point
  10. I left the last bracket off the other day. We all do it.
    1 point
  11. When you use a dcl edit box it only accepts or out puts a string even though you will seem to put in a number like 123 the dcl returns "123" as a string , so Steven P is correct need to convert to a number atof for real or atoi for integer. In the multi getvals you can save a variable say num = 123, then in the multi call just convert it to a string and it will be displayed. Please note that the Multi getvals returns a list of the values, so as you only have one then use the (car to get the 1st value in the list. (if (not AH:getvalsm)(load "Multi Getvals.lsp")) ;;BigAl's Dialog Box (if (= n nil)(setq n 100)) (setq n (atof (car (AH:getvalsm (list "Enter" "How Many More? " 5 4 (rtos n 2 0))))))
    1 point
  12. Try This. See the comments in the file for the changes. MedZ v3.lsp
    1 point
  13. First of all happy new year for everybody. Now about this app , RlxPaste. I often have need to copy some objects from one dwg to another. Although I allready have written a 'perfect' app for that , all my colleagues use it and I didn't want to add my junk symbols to it. So I came up with this app , which allows you to simply create symbols on the fly for local use. I think / hope the interface is self explanatory. You can control the grid in the setup dialog and you can select the folder where you save your symbols. Btw , double click to insert and if you want to delete item , click delete button and then click on image to delete. You can add a complete folder and its subfolders at once with the button Add Folder in the main dialog. This is usefull when you have for example a cd from a vendor or client with their company symbols. Hope it is usefull. gr. Rlx RlxPaste.dcl RlxPaste.LSP
    1 point
×
×
  • Create New...