Jump to content

tag and line attribution from block to blocks


Kasus

Recommended Posts

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 by SLW210
Added Code Tags!
Link to comment
Share on other sites

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.

 

image.thumb.png.f2f85372a9d9180703194886f2af2f08.png

 

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...