Kasus Posted October 13, 2023 Posted October 13, 2023 (edited) Hi everyone, new here but following some troubleshooting for some time. I'm trying to learn lisp on my own (when time and opotunities are a thing) and trying to make use of it to improve my work to make it a "easy" task on the run. Can't code on my own yet but have been trying (poorly) to read it and change it to my needs, but I came to a wall and hope if anyone could help out. Enough about the boring me and more about what really drives people here What I can do with separated tasks: Part1: I have Block1 and Block 2.1, Block 2.2, Block 2.3, etc.... I draw a line from Origin to (multiselection) Destination. Part2: Get in memory a specific tag from Origin and insert it on another tag on the Destination, and repeat, repeat, repeat... I have 2 codes for that that I use from Lee Mac website and some other post from this forum (tnx for that guys). Now what I was trying to do: Draw the polylines from Origin-> (multiselection) Destination AND add that tag value simultaniously. But having a hard time figuring out how to change/add the code for both to work as 1. Any sugestions pls? this is the code I have right now on its working state (the repeated ";"' lines are just to help me distinguish each part of the other): (defun c:tags ( / sText) ;;;;;;;;;;;;;;;;;;;;;;;; (defun TCC_copyAttribute (source / blk ) (if (setq blk (entsel "\nSelect source block: ")) (setq sText (LM:vl-getattributevalue (vlax-ename->vla-object (car blk)) source)) ) ) ; (defun LM:vl-getattributevalue ( blk tag ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes)) ) ;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun TCC_pasteAttribute (dest / blk) (if (setq blk (entsel "\nSelect destination block: ")) (LM:vl-setattributevalues (vlax-ename->vla-object (car blk)) (list (cons dest sText)) ) ) ) ; (defun LM:vl-setattributevalues ( blk lst / itm ) (foreach att (vlax-invoke blk 'getattributes) (if (setq itm (assoc (vla-get-tagstring att) lst)) (vla-put-textstring att (cdr itm)) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (while (TCC_copyAttribute "EQUIP_NAME") (TCC_pasteAttribute "EQUIP_NAME") ) princ() ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:drop (/ base ss i) (if ( and ( setq base ( car (entsel "\nSelect base block: ") ) ) (or (= "INSERT" (cdr (assoc 0 (entget base)))) (prompt "\nWrong selection, not a block.") ) (setq base (cdr (assoc 10 (entget base)))) (princ "\n...and blocks to connect to, ") (setq ss (ssget '((0 . "INSERT")))) ) ; ; ; (repeat ( setq i (sslength ss)) (command "_.PLINE""_none" (trans base 0 1)"_none" (trans (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))) 0 1)"") ) ) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; test.lsp Edited October 13, 2023 by SLW210 Added Code Tags! Quote
SLW210 Posted October 13, 2023 Posted October 13, 2023 Please use Code Tags (the <> in the editor) for your code. I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Please post in the correct forum. Quote
mhupp Posted October 13, 2023 Posted October 13, 2023 Welcome, One thing chatgpt is good for is learning how to code. You can give it snippets and it will then start to explain whats going on. You can also ask it follow up questions, to explain in more detail, or about a specific part of the code. Just keep in mind what its telling you can be wrong. People end up thinking that all you will need to do is feed it 2 or 3 sentences and get 100% complete working code. and for simple things that can be true but for the most part it isn't there yet. Also its better to post a sample drawing along with code. because you might not be aware of all the capabilities when asking how to do something. someone will probably beat me too it but will read over this later today. Quote
BIGAL Posted October 14, 2023 Posted October 14, 2023 Like Mhupp "Also its better to post a sample drawing" show before then after. 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.