Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Today
  3. Dayananda

    Open named viewports with lisp

    finally I wrote a script. Now I want to add delay between each views 1954 delay 1955 etc. ^C^C_-view;R;1954;1955;
  4. Dayananda

    Open named viewports with lisp

    It can open in view command. I need to feed relevant names one after another including delay function.
  5. Yesterday
  6. @Nikon PS: I think it’s better if you copy the code into "acad2021.lsp" and not into "acad2021Doc.lsp" because the content of the latter is loaded afterwards.
  7. Yes I know. 'vlr-remove-all' is executed during loading so that any reactor created with the previous code is erased. It was a quick solution. I assumed that Nikon does not use reactors. But it is probably a risky assumption. So I guess I am "obliged" to fix it. Below, a solution that keeps the reactors even if the drawing closure is canceled, that respects any reactor created by another application, and that regenerates them in each drawing. (defun fota (/ arch cad cmd mens etq letq n er lx) (defun pregunta (a b / cad) (cond ((member (strcase (car b)) '("CLOSE" "_CLOSE" "QUIT" "_QUIT" "EXIT" "_EXIT")) (if (and *lstCmds* (setq mens (cmdsCargados)) (= (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "Print commands on screen?" 0 "Save commands name" 4) 6) ) (progn (vla-AddMText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point (getpoint "\nInsertion point...")) 100 mens) (vlax-invoke-method (vlax-get-acad-object) 'Update) ) ) ) ((= (type a) 'VLR-Lisp-Reactor) (if (not (member (setq cad (substr (car b) 4 (- (strlen (car b)) 4))) *lstCmds*)) (setq *lstCmds* (cons (substr (car b) 4 (- (strlen (car b)) 4)) *lstCmds*)) ) ) ) ) (setq letq '("Nikon1" "Nikon2") *afI* nil) (foreach r (vlr-reactors) (foreach er (cdr r) (if (member (setq etq (vlr-data er)) letq) (if (wcmatch etq "Nikon1,Nikon2") (setq lx (cons er lx)) ) ) ) ) (if lx (foreach r lx (vlr-remove r))) (foreach sim (atoms-family 0) (if (wcmatch (setq cmd (strcase (vl-princ-to-string sim) T)) "c:*") (setq *afI* (cons sim *afI*)) ) ) (setq *r* (vlr-command-reactor "Nikon1" '((:vlr-commandwillStart . pregunta)))) (setq *r1* (vlr-lisp-reactor "Nikon2" '((:vlr-lispwillstart . pregunta)))) ) (defun cmdsCargados (/ cad) (setq *cadCmds* nil) (foreach sim (atoms-family 0) (if (not (member sim *afI*)) (if (and (wcmatch (setq cad (strcase (vl-princ-to-string sim) T)) "c:*") (member (strcase (substr cad 3)) *lstCmds*) ) (setq *cadCmds* (strcat (if *cadCmds* (strcat *cadCmds* "\n") "\\C1Comandos utilizados durante la sesi贸n:\\C256\n") (substr cad 3))) ) ) ) *cadCmds* ) (fota)
  8. Nice one Bigal, Thank you!
  9. Not sure if this is useful it tracks all commands used in a session Productivity_Analysis_Tool.lsp
  10. Not sure if the lisp by YMG will read 3dfaces. CIV3d will do it same with other civil packages like Civil Site Design.TriangV0.6.7.LSP
  11. BIGAL

    Open named viewports with lisp

    The probable answer is CVPORT but how are you making the animation ? You can in a lisp change layouts and viewports use the DELAY command to slow down the changing between layouts etc.
  12. BIGAL

    updating an exploded material table

    If this is Road pavement volumes then may need CIV3D or Civil Site Design which have volume reports which include volume & area between chainages.
  13. There are no commands - just load it, use a few LISP commands, and then save your drawing.
  14. Yes I suppose if the log is to be maintained continuously, existing content could be parsed and updated accordingly - if more than just the OP are using this code, I'll look to update it.
  15. I don't understand, if your just picking two points why are you not just doing (command "_.BREAK" "0,0.3" "0,-0.3")
  16. Thank you Tsuky, works exactly as i needed.
  17. Hi, With your drawing, this code will correct the polylines. To be adapted if used in another drawing (ssget filter) (vl-load-com) (defun c:Correct3DPL ( / ss AcDoc Space nb n ename obj l_pt lay new_obj) (setq ss (ssget "_X" '((0 . "POLYLINE") (67 . 0) (8 . "CTL_PNT") (66 . 1) (70 . 9)))) (cond (ss (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) nb 0 ) (repeat (setq n (sslength ss)) (setq ename (ssname ss (setq n (1- n))) obj (vlax-ename->vla-object ename) l_pt (vlax-get obj 'Coordinates) lay (vlax-get obj 'Layer) ) (cond ((eq (length l_pt) 12) (vla-delete obj) (setq new_obj (vlax-invoke Space 'Add3dPoly (cdddr l_pt))) (vla-put-Closed new_obj :vlax-true) (vla-put-Layer new_obj lay) (setq nb (1+ nb)) ) ) ) (princ (strcat "\n" (itoa nb) " polylines corrected.")) ) ) (prin1) )
  18. Lee it is a rare day when I find an improvement for you, and it might be today... might be... In your onsave would it be preferable to take any strings that 'sel' finds in the ssget and append the new commands to them? Maybe put some sort of delimitator between old and new strings? Reason I ask, it is not unusual for me to complete a drawing over a few sessions - end of day into the next day being most common - which means the reactors will be reset... but the commands used will still need to be listed.
  19. Yes, I may have opened the same drawing several times. I noticed that if I use 2 lisps, then close the file, but cancel closing it and continue working in this file with new codes, when I close it again, the suggestion to save the list of commands does not appear...
  20. not in this case , unless i am doing something wrong. I have attached example dwg. Basically i had 3DFaces as Triangles and converted them using lisp into 3dpolyline Triangles, but it creates 4 Vertices for each Triangle, another lisp which supposed to create contours over triangles refusing to do so and say 3dpolylines are not closed polylines. sample.dwg
  21. Please explain how to use it correctly, which command to call?
  22. Thanks @GLAVCVS I would advise against (vlr-remove-all), as this will remove all reactors defined within the session, not only those defined by your program.
  23. Great code, as always, Mr. Lee As for mine, I think I forgot that some reactors are persistent. So, Nikon, the problem is that you must have opened the same drawing several times in the same AutoCAD session, and several prompts have accumulated, repeating the request several times. That problem shouldn't occur anymore with this new code. Also, you'll be able to see the text inserted before confirming the closing of the drawing. Simply replace the "fota" function in your "acad2021Doc.lsp" with this new one. (defun fota (/ arch cad cmd mens) (defun pregunta (a b / cad) (cond ((= (car b) "CLOSE") (if (and *lstCmds* (setq mens (cmdsCargados)) (= (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "驴Dejar en el dibujo un MTEXT con todos los comandos utilizados?" 0 "Guardar comandos usados" 4) 6) ) (progn (vlr-remove-all) (vla-AddMText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point (getpoint "\nInsertion point...")) 100 mens) (vlax-invoke-method (vlax-get-acad-object) 'Update) ) (vlr-remove-all) ) ) ((= (type a) 'VLR-Lisp-Reactor) (if (not (member (setq cad (substr (car b) 4 (- (strlen (car b)) 4))) *lstCmds*)) (setq *lstCmds* (cons (substr (car b) 4 (- (strlen (car b)) 4)) *lstCmds*)) ) ) ) ) (vlr-remove-all) (foreach sim (atoms-family 0) (if (wcmatch (setq cmd (strcase (vl-princ-to-string sim) T)) "c:*") (setq *afI* (cons sim *afI*)) ) ) (setq *r* (vlr-command-reactor nil '((:vlr-commandwillStart . pregunta)))) (setq *r1* (vlr-lisp-reactor nil '((:vlr-lispwillstart . pregunta)))) )
  24. Here's a quick & dirty version - it's not advisable to prompt the user for any input as part of a reactor callback. (defun init ( ) (foreach grp (vlr-reactors :vlr-command-reactor :vlr-lisp-reactor) (foreach rtr (cdr grp) (if (= "lisp-commands" (vlr-data rtr)) (vlr-remove rtr) ) ) ) (setq lisp-command-list nil) (vlr-command-reactor "lisp-commands" '((:vlr-commandwillstart . onsave))) (vlr-lisp-reactor "lisp-commands" '((:vlr-lispwillstart . onlisp))) (princ) ) (defun onsave ( rtr arg / idx lyr sel str ) (setq lyr "lisp-commands") (cond ( (not arg)) ( (not (wcmatch (setq arg (strcase (car arg))) "SAVE,QSAVE,SAVEAS"))) ( lisp-command-list (if (setq sel (ssget "_X" (list (cons 8 lyr)))) (repeat (setq idx (sslength sel)) (entdel (ssname sel (setq idx (1- idx)))) ) ) (setq str "") (foreach itm (vl-sort lisp-command-list '(lambda ( a b ) (> (cdr a) (cdr b)))) (setq str (strcat str "\\P" (car itm) "\t\t" (itoa (cdr itm)))) ) (makelayer lyr) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(010 0.0 0.0) (cons 1 (substr str 3)) (cons 8 lyr) ) ) ) ) (princ) ) (defun onlisp ( rtr arg / fun itm ) (cond ( (not arg)) ( (wcmatch (setq arg (strcase (car arg))) "~(C:*)")) ( (setq fun (substr arg 4 (- (strlen arg) 4)) itm (assoc fun lisp-command-list) ) (setq lisp-command-list (subst (cons (car itm) (1+ (cdr itm))) itm lisp-command-list)) ) ( (setq lisp-command-list (cons (cons fun 1) lisp-command-list))) ) (princ) ) (defun makelayer ( lay ) (if (not (tblobjname "layer" lay)) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(070 . 0) (cons 2 lay) '(062 . 8) '(290 . 0) ) ) ) ) (vl-load-com) (init)
  25. I load programs and use them.
  26. I need you to explain a little more. Did you use multiple Lisp commands or just load files? Take a screenshot of the code you pasted into the "acad2021Doc.lsp" file.
  27. I tested the code a bit more, sometimes the window with the message "Display commands on the screen?" does not work correctly. I have to click "Yes" several times, I specify the insertion point of the text, but the window appears again, and if I click "No", the window also appears several times. And one more small note, when I specify the insertion point, I don't see how the text is inserted. A window about saving the drawing appears immediately… Maybe I'm doing something wrong...
  28. Steven P

    Open named viewports with lisp

    Maybe this might help: Lee Macs option at the end might give you a start. Do you want it to open the viewports automatically or with the user perhaps pressing say 'space' bar?
  1. Load more activity
×
×
  • Create New...