TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: amc.dicsac on February 24, 2017, 04:40:34 PM
-
Hi, how are you
Is there any subfunction that allows you to select blocks with attributes and change them automatically
Thank you
-
There are hundreds of examples (https://www.google.com/search?q=getattribute+site%3Atheswampt.org&oq=getattribute+site%3Atheswampt.org&aqs=chrome..69i57.18151j0j7&sourceid=chrome&ie=UTF-8#q=getattribute+site:theswamp.org&*) here.
-
H Ronjonp i, how are you
This subfunction I found in this link would probably work with ssget
https://www.theswamp.org/index.php?topic=49300.msg543974#msg543974 (https://www.theswamp.org/index.php?topic=49300.msg543974#msg543974)
(defun _putattvalue
(block tag value
/ att flag
) att
value
)
)
)
)
)
flag
)
-
Here are numerous ways:
http://www.lee-mac.com/attributefunctions.html
When you're stuck at learning LISP always check Lee Mac's stuff (IMO hes the best learning material). :D
-
Do you want to select the attributes themselves? If so, take the code from here. (https://www.theswamp.org/index.php?topic=19886.msg488544#msg488544)
-
NO, the block has two attributes the first tag1 and the other tag2, the tag1 I want to add 33 and the tag2 subtract 4, I do not want to apply entsel because I would have to select one by one that is why I asked if ssget could extract the content Of the attributes.
-
Ssget, No. ssget will select "space" entities, not nested entities. Use ssget to select the blocks, then step through the attributes ob the selected blocks (testing the tag) and make the changes there.
The code I linked to will allow you to select the attribute entities like ssget.
So you have two options on how to get to the attributes within a block now. Choose which way works for you. Post code once you get stuck.
-
Hi, how are you, here I have my code almost finished, since I have a problem I do not know because it sends the message
Select objects:; Error: bad argument type: fixnump: "2"
Eh analyzed every section of the code but I do not find the problem, I would appreciate the help
-
This:
(setq off1 (itoa TotaLam)))
Should be:(setq off1 (atoi TotaLam)))
Similarly:
(setq off2 (itoa ContLam)))
Should be:
(setq off2 (atoi ContLam)))
-
Thanks Lee, but now every time I enter enter to keep the same value I get this message
Ingresa ToTal lamina <43>:
; Error: bad argument type: stringp 43
-
Sorry, I now see that you are already converting the default values to integers earlier in the code - in this case, change the lines to:
(setq off1 TotaLam))
(setq off2 ContLam))
-
When making that change, I no longer keep the last values entered, now the lisp has worsened
-
Somewhere you are passing a string variable where you want a number variable. I think it has something to do with 'off3', as you can see from the code below you are assigning 'off2' to two different types of variables.
(if (setq off2 (getint (strcat "\nIngresa inicio <" (itoa ContLam) ">: ")))
(setenv "SaveNumberSheet\\ContLam" (itoa off2))
(setq off2 (itoa ContLam)))
The first line is asking for an integer, but the last line is converting an Integer TO Alpha.
To help find the location of the error, define an error function with a call to '(vl-bt)'.
(defun *error* (msg) (vl-bt))
-
When I start lisp I have this code
(not (setq ContLam off3
))) ;;Returns "nil" (setenv "SaveNumberSheet\\ContLam" (setq ContLam
"1"));;Returns "1" )
I would like to call the code again to save the result of the sum
But every time I call it it recognizes at first off3 as an empty value ie nill
My problem would be to assign a value to off3 to convert it to a string then convert it to a number, execute the sum and the last value to convert it back into a string so that it is stored in off3
-
I was able to solve the problem, thank you very much for the help you have been giving me :yay!:
-
That is good to hear. You're welcome.
Maybe you can post the working code, so others can see how you solved the issue.