Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. i get an error like this: error: bad argument type: VLA-OBJECT <Entity name: 181bbe5aaf0> Is there anything I did wrong? But, thank you for helping me
  3. I don't know what's wrong, but I get an error like this: error: bad argument type: VLA-OBJECT <Entity name: 181bbe5aaf0> But, thank you for helping me
  4. Do you want 1 string search to excel or is it do repeated searches. Please confirm.
  5. Today
  6. "Sorry got caught up in something. select the block then select the attribute "text" you want to update." Just select attribute ! As mentioned using nentsel this can return the tag name, then use (ssget pt) where pt is the (cadr (nentsel)) then (ssname ss 0) (setq ent (nentsel "\nPick an attribute ")) (setq pt (cadr ent)) (setq tagname (cdr (assoc 2 (entget (car ent))))) (setq ss (ssget pt)) (setq blk (ssname ss 0)) (setq blkname (cdr (assoc 2 (entget blk)))) ; dont really need this for the task
  7. You can be lucky owe me a cup of coffee. ; Oct 2022 ; By AlanH makes a legend of used layers and blocks. (defun RemoveDupes (InLst / OutLst CarElm) (while InLst (setq InLst (vl-remove (setq CarElm (car InLst)) (cdr InLst)) OutLst (cons CarElm OutLst) ) ) ) (defun makelegend ( / ss lst lstrem obj pt pt2 ltname x val bname) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setvar 'textstyle "Standard") (setq oldlay (getvar 'clayer)) (setvar 'clayer "0") (setvar 'ctab "Model") (setq ss (ssget "X" (list (cons 410 "Model")))) (setq lst '()) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq lst (cons (list (vla-get-layer obj) (vlax-get obj 'Linetype)) lst)) ) (setq lst (RemoveDupes lst)) (setq lst (vl-sort lst '(lambda (x y) (< (car x) (car y))))) (setq pt (getpoint "\nPick point for line legend ")) (setq pt2 (mapcar '+ pt (list 125.0 0.0 0.0))) (foreach ltname lst (command "line" pt (mapcar '+ pt (list 20.0 0.0 0.0)) "") (command "chprop" (entlast) "" "LA" (car ltname) "LT" (cadr ltname) "S" 0.25 "") (command "text" (mapcar '+ pt (list 25.0 0.0 0.0)) 2.5 0.0 (car ltname)) (setq pt (mapcar '+ pt (list 0.0 10.0 0.0))) ) (setq lst '()) (setq attreq 0) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (if (= (vla-get-objectname obj) "AcDbBlockReference") (setq lst (cons (vla-get-name obj) lst)) ) ) (setq lst (RemoveDupes lst)) (setq lst (vl-sort lst '(lambda (x y) (< x y)))) (foreach val lst (if (wcmatch val "*U#*" ) (setq lst (vl-remove val lst)) ) ) (foreach bname lst (progn (command "text" (mapcar '+ pt2 (list 25.0 0.0 0.0)) 2.5 0.0 bname) (command "-insert" bname pt2 1 1 0) (setq pt2 (mapcar '+ pt2 (list 0.0 10.0 0.0))) (setq obj (vlax-ename->vla-object (entlast))) (vla-GetBoundingBox obj 'minpoint 'maxpoint) (setq pointmin (vlax-safearray->list minpoint)) (setq pointmax (vlax-safearray->list maxpoint)) (setq ht (- (cadr pointmax)(cadr pointmin))) (setq xscale (/ 5.0 ht)) (vla-put-xscalefactor obj xscale) (vla-put-yScaleFactor obj xscale) ) ) (setvar 'osmode oldsnap) (setvar 'clayer oldlay) (princ) ) (makelegend)
  8. Sorry got caught up in something. select the block then select the attribute "text" you want to update. ;;----------------------------------------------------------------------------;; ;; PULL BLOCKS NAME TO UPDATE ATTRIBUTE (defun C:ATTBLKNAME () (C:ABN)) (defun C:ABN (/ SS lst Name Att) (while (setq ent (car (entsel "\nSelect Block"))) ;gets an entity name using while will keep repeating if you keep selecting an entity (progn (if (= (cdr (assoc 0 (setq lst (entget ent)))) "INSERT") ;test if its a block (progn (setq Name (cdr (assoc 2 lst))) ; pulls the name (setq Att (car (nentsel "Select Attribute Text to update"))); nentsel can get entity names inisde blocks (vla-put-textstring Att Name) ;update entity with name ) (progn ;if entity isn't a block will prompt user (prompt "\nNot a Block Pick again") (c:ABN) ;and start the comman over again. ) ) ) ) (princ) ) --edit added some comments
  9. Is it possible to get lines with all layer properties using lisp, and next to each line, specify the name of the layer. Maybe there is already such a lisp?
  10. I apologize in advance, I don't understand the syntax. I'm still a beginner at this. What I want to get after selecting the attribute is that the attribute value will contain the name of the object block that I previously selected.
  11. I got this error: error: ADS request error do you know what happened?
  12. Assuming that you have geometry like this: and you want to fill in the corner like this: Define a UCS for each of the end planes of the welds and create closed polylines (red and green below) on each plane. Use loft to create the solid between them.
  13. Chage "ATT ID" to what ever the tag is if you wanted to update the Date text (setpropertyvalue (ssname att 0) "DATE" "Today")
  14. You didn't answered to question : What do you get when you pick an attribute with this syntax : (cdr (assoc 2 (entget (car (nentsel))))) Then you should nest ATTRIB entity to desired block with this firstly posted code in this post : https://www.theswamp.org/index.php?topic=55172.msg594767#msg594767 After you nest ATTDEF, change line 8 in my posted code with correct TAGNAME you pulled from written syntax : (cdr (assoc 2 (entget (car (nentsel)))))... Here is the code where you should alter line 8 : (defun c:blknames2attvalues ( / s i e n x ) (prompt "\nSelect blocks to fill their attributes with their block names...") (if (setq s (ssget "_:L" (list (cons 0 "INSERT") (cons 66 1)))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) (setq n (cdr (assoc 2 (entget e)))) (while (= (cdr (assoc 0 (setq x (entget (setq e (entnext e)))))) "ATTRIB") (if (= (strcase (cdr (assoc 2 x))) (strcase TAGNAME)) (entupd (cdr (assoc -1 (entmod (subst (cons 1 n) (assoc 1 x) x))))) ) ) ) ) (princ) ) HTH. M.R.
  15. I got this error: error: ADS request error do you know what happened?
  16. Change this line in qouted code : (setpropertyvalue (ssname att 0) "ATT_ID" n) To this line : (setpropertyvalue (ssname att 0) "TextString" n)
  17. object block and attribute definition are separate objects
  18. What code do I need to enter to get the TagName?
  19. @Kvlar Just another question : Is your attribute real attribute nested into block, or it's separate object still unnested as ATTDEF waiting to be nested into desired block... If it's ATTDEF, then this mhupp's code is good - I changed it just slightly... ;;----------------------------------------------------------------------------;; ;; Pull block name to update Attribute ;; https://www.cadtutor.net/forum/topic/85706-can-anyone-help-me-get-the-attribute-value-based-on-the-block-name/ (defun c:B2A (/ s n att) (prompt "\nSelect Blocks to Pull its Names...") (while (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (progn (setq n (getpropertyvalue (ssname s 0) "Name")) (prompt "Select Attribute Definition to update") (setq att (ssget "_+.:E:S" '((0 . "ATTDEF")))) (setpropertyvalue (ssname att 0) "TextString" n) ) ) (princ) )
  20. @Kvlar What do you get when you pick an attribute with this syntax : (cdr (assoc 2 (entget (car (nentsel))))) You should get TAGNAME of your attribute... Then change my code with this TAGNAME string in line 8 :
  21. I've tried it, but I get an error like this: error: bad argument type: consp "INSERT"
  22. Give this a try not tested and you need to update the "ATT ID" to what ever you want the block name to be. You could also update the ssget with the block name (line 7) to limit only selecting the block with the attribute. if the attribute is in the same block ;;----------------------------------------------------------------------------;; ;; Pull block name to update Attribute ;; https://www.cadtutor.net/forum/topic/85706-can-anyone-help-me-get-the-attribute-value-based-on-the-block-name/ (defun c:B2A (/ s n att) (prompt "\nSelect Blocks to Pull its Names...") (while (setq s (ssget "_+.:E:S" '((0 . "INSERT")))) (progn (setq n (getpropertyvalue (ssname s 0) "Name")) (prompt "Select Block with Attribute to update") (setq att (ssget "_+.:E:S" '((0 . "INSERT")))) (setpropertyvalue (ssname att 0) "ATT ID" n) ) ) (princ) )
  23. this is almost what I need. but what I need is something like I have 1 object block with name A and 1 object attribute and when I run the autolisp command, I select the block object with the name A and I click on the object attribute so that the attribute value contains the block name of object A.
  24. Basically I don't know why do you need this, but here is the code... It changes values of all attributes to match blocks names... And I doubt you're searching for this as I am guessing that you need to fill just single attribute by each block; you just didn't wrote which attribute is that - it's tag name... (defun c:blknames2attvalues ( / s i e n x ) (prompt "\nSelect blocks to fill their attributes with their block names...") (if (setq s (ssget "_:L" (list (cons 0 "INSERT") (cons 66 1)))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) (setq n (cdr (assoc 2 (entget e)))) (while (= (cdr (assoc 0 (setq x (entget (setq e (entnext e)))))) "ATTRIB") (entupd (cdr (assoc -1 (entmod (subst (cons 1 n) (assoc 1 x) x))))) ) ) ) (princ) )
  25. is there anyone who can help me? I need autolisp code with a function to fill in attribute values based on the block name. For example, I have an object block with the name A and an object attribute, when I run the autolisp command, I select the object with the name A and I click on the object attribute so that the attribute value contains the name of the object block A. is this possible to create by autolisp? Thank you
  26. Nikon

    Lisp divide pline

    You can just select a line... Without specifying points...
  1. Load more activity
×
×
  • Create New...