All Activity
- Today
-
Can anyone help me? get the attribute value based on the block name
Kvlar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
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. -
Can anyone help me? get the attribute value based on the block name
Kvlar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
I got this error: error: ADS request error do you know what happened? -
lrm started following How to close weld gap in AutoCad 3D
-
How to close weld gap in AutoCad 3D
lrm replied to Emboss 2014's topic in AutoCAD 3D Modelling & Rendering
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. -
Can anyone help me? get the attribute value based on the block name
mhupp replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
Chage "ATT ID" to what ever the tag is if you wanted to update the Date text (setpropertyvalue (ssname att 0) "DATE" "Today") -
Can anyone help me? get the attribute value based on the block name
marko_ribar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
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. -
Can anyone help me? get the attribute value based on the block name
Kvlar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
I got this error: error: ADS request error do you know what happened? -
Can anyone help me? get the attribute value based on the block name
marko_ribar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
Change this line in qouted code : (setpropertyvalue (ssname att 0) "ATT_ID" n) To this line : (setpropertyvalue (ssname att 0) "TextString" n) -
Can anyone help me? get the attribute value based on the block name
Kvlar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
object block and attribute definition are separate objects -
Can anyone help me? get the attribute value based on the block name
Kvlar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
What code do I need to enter to get the TagName? -
Can anyone help me? get the attribute value based on the block name
marko_ribar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
@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) ) -
Can anyone help me? get the attribute value based on the block name
marko_ribar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
@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 : -
Can anyone help me? get the attribute value based on the block name
mhupp replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
forgot the ' in the ssgets should work now. -
Can anyone help me? get the attribute value based on the block name
Kvlar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
I've tried it, but I get an error like this: error: bad argument type: consp "INSERT" -
mhupp started following Can anyone help me? get the attribute value based on the block name
-
Can anyone help me? get the attribute value based on the block name
mhupp replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
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) ) -
Can anyone help me? get the attribute value based on the block name
Kvlar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
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. -
marko_ribar started following Can anyone help me? get the attribute value based on the block name
-
Can anyone help me? get the attribute value based on the block name
marko_ribar replied to Kvlar's topic in AutoLISP, Visual LISP & DCL
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) ) -
Mohamed metwally joined the community
-
masum joined the community
-
Kvlar started following Can anyone help me? get the attribute value based on the block name
-
Can anyone help me? get the attribute value based on the block name
Kvlar posted a topic in AutoLISP, Visual LISP & DCL
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 -
You can just select a line... Without specifying points...
-
REBAR QUANTITIES AND LENGTH CALCULATIONS WITH TABLE TO EXCEL
hosneyalaa replied to achila's topic in AutoLISP, Visual LISP & DCL
and excel file - Yesterday
-
REBAR QUANTITIES AND LENGTH CALCULATIONS WITH TABLE TO EXCEL
BIGAL replied to achila's topic in AutoLISP, Visual LISP & DCL
Using the in built tools may be the way to go as suggested, because everybody draws objects in different ways Layers, using blocks, Xdata to mention a few ways of getting data about your bars. You may have to look at a semi custom make a table of bar details, some one may have something close that can be edited, remember a bar can be straight, hooked, curved and so on not just a length. Can you post a sample dwg ? Ps make table & export to Excel can be done. -
dynamic block parameter to Mleader issue
EYNLLIB replied to EYNLLIB's topic in AutoLISP, Visual LISP & DCL
as an update, i fixed the code using VLAX-INVOKE method to create the mleader: it's friday...give me a break (defun LM:getdynpropvalue (blk prp) (setq prp (strcase prp)) (vl-some '(lambda (x) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'Value))) (vlax-invoke blk 'GetDynamicBlockProperties))) (defun c:swtest () (setq blockName (car (entsel "\nSelect Block: "))) (if (and blockName (eq (cdr (assoc 0 (entget blockName))) "INSERT")) (progn (setq vlaBlock (vlax-ename->vla-object blockName)) (setq SW_LENGTH (LM:getdynpropvalue vlaBlock "SW_LENGTH")) (if SW_LENGTH (progn (setq textString (strcat "SW_LENGTH: " (rtos SW_LENGTH 2 2))) (princ (strcat "\n" textString)) (if (setq ins (getpoint "\nSpecify start point for MLeader: ")) (progn (setq endPoint (getpoint "\nSpecify end point for MLeader: " ins)) (setq curlay (getvar "CLAYER")) (setvar 'CMDECHO 0) (command "_.undo" "_group") (setvar 'CLAYER "S - TEXT") (command "CMLEADERSTYLE" "NORMAL - SW") (setvar 'CMDECHO 1) (initcommandversion) ;; Creating MLeader using vlax-invoke method (setq mleaderObj (vlax-invoke (vlax-get (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'PaperSpace 'ModelSpace)) 'AddMLeader (append ins endPoint) 0)) (vla-put-TextString mleaderObj textString) (setvar 'CMDECHO 0) (command "CMLEADERSTYLE" "Normal") (command "_.LAYER" "_SET" curlay "") (command "_.undo" "_end") (setvar 'CMDECHO 1) (princ "MLeader with SW_LENGTH created.")) (alert "Insertion point not specified!"))) (alert "SW_LENGTH attribute not found!"))) (alert "Selected entity is not a block!")) (princ))- 2 replies
-
- 1
-
- lisp
- dynamic block
-
(and 1 more)
Tagged with:
-
Am I missing something? Is it not pick a start and end point, then draw the bars with overlap and a max length of 11700. Include dims etc.
-
dynamic block parameter to Mleader issue
EYNLLIB replied to EYNLLIB's topic in AutoLISP, Visual LISP & DCL
For reference, I have a similar routine that grabs the length of a polyline and appends the mleader content with some custom text and the length that works perfectly; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CUSTOM FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun my-mod (x y) (- x (* y (fix (/ x y)))) ) (defun dot-product (vec1 vec2) (+ (* (nth 0 vec1) (nth 0 vec2)) (* (nth 1 vec1) (nth 1 vec2))) ) (defun list->points (lst / result x y) (setq result '()) (while lst (setq x (car lst) y (cadr lst) lst (cddr lst)) (setq result (append result (list (list x y)))) ) result ) (defun distance (pt1 pt2) (sqrt (+ (expt (- (car pt2) (car pt1)) 2) (expt (- (cadr pt2) (cadr pt1)) 2))) ) (defun distance-to-segment (p a b) (setq l2 (distance a b)) (if (= l2 0.0) (distance p a) (progn (setq denominator (dot-product (mapcar '- b a) (mapcar '- p a))) (setq temp (/ denominator (dot-product (mapcar '- b a) (mapcar '- b a)))) (setq projection (mapcar '+ a (mapcar '* (mapcar '- b a) (list temp temp temp)))) (distance p projection) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END CUSTOM FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN PROGRAM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:sw () (initget 1 "1 2 3 4 5") (setq userNumber (getint "\nEnter Shearwal Type (1-5): ")) (if userNumber (progn (setq selectedEntity (entsel "\nSelect a polyline: ")) (if (or (null selectedEntity) (/= "LWPOLYLINE" (cdr (assoc 0 (entget (car selectedEntity)))))) (progn (princ "\nCancelled or not a polyline.") (exit) ) ) (setq pickedPoint (cadr selectedEntity)) (setq polyline (vlax-ename->vla-object (car selectedEntity))) (setq vertices (vlax-get polyline 'Coordinates)) (setq vertices (list->points vertices)) (setq numVertices (length vertices)) (setq closestSegment nil) (setq i 0) (while (< i numVertices) (setq pt1 (nth i vertices)) (setq pt2 (nth (my-mod (+ i 1) numVertices) vertices)) (setq distToSegment (distance-to-segment pickedPoint pt1 pt2)) (if (or (null closestSegment) (< distToSegment (car closestSegment))) (setq closestSegment (cons distToSegment (list pt1 pt2))) ) (setq i (+ i 1)) ) (setq segmentlength (distance (nth 0 (cdr closestSegment)) (nth 1 (cdr closestSegment)))) (setq roundedLength (fix (+ 0.5 segmentlength))) (setq feet (fix (/ roundedLength 12))) (setq inches (rem roundedLength 12)) (setq str (strcat "SW" (itoa userNumber) " (" (itoa feet) "'-" (itoa inches) "\")")) (if (setq ins (getpoint "\nSpecify start point for mleader: ")) (progn (setq endPoint (getpoint "\nSpecify end point for mleader: " ins)) (setq curlay (getvar "CLAYER")) (setvar 'CMDECHO 0) (setvar 'CLAYER "S - TEXT") (command "cmleaderstyle" "Normal - SW") (setvar 'CMDECHO 1) (setq mleaderObj (vlax-invoke (vlax-get (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'PaperSpace 'ModelSpace ) ) 'AddMLeader (append ins endPoint) 0 ) ) (vla-put-TextString mleaderObj str) (setvar 'CMDECHO 0) (command "REGEN") (setvar 'CLAYER curlay) (command "cmleaderstyle" "Normal") (setvar 'CMDECHO 1) ) ) ) ) (princ (strcat "\nExact Length of Shearwall: " (rtos segmentlength))) ; Print the shearwall length (princ) )- 2 replies
-
- lisp
- dynamic block
-
(and 1 more)
Tagged with:
-
I'm almost there with my workflow, but I need a little help to get it just right. Here's what I'm trying to do: Type command Select block Pick Mleader arrow location Pick Mleader landing location Mleader content should automatically populate with the "SW_LENGTH" parameter from the block Everything works great up until step 5. After I pick both Mleader points, the Mleader text box opens for me to fill out (it's blank). But if I click in the drawing area, it exits the text box and fills in the correct info. So, how do I skip that last step and have the Mleader content fill in automatically without Autocad opening the text edit box? ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue (blk prp) (setq prp (strcase prp)) (vl-some '(lambda (x) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'Value))) (vlax-invoke blk 'GetDynamicBlockProperties))) (defun c:swtest () (setq blockName (car (entsel "\nSelect Block: "))) (if (and blockName (eq (cdr (assoc 0 (entget blockName))) "INSERT")) (progn (setq vlaBlock (vlax-ename->vla-object blockName)) (setq SW_LENGTH (LM:getdynpropvalue vlaBlock "SW_LENGTH")) (if SW_LENGTH (progn (setq textString (strcat "SW_LENGTH: " (rtos SW_LENGTH 2 2))) (princ (strcat "\n" textString)) (if (setq ins (getpoint "\nSpecify start point for MLeader: ")) (progn (setq endPoint (getpoint "\nSpecify end point for MLeader: " ins)) (setq curlay (getvar "CLAYER")) (setvar 'CMDECHO 0) (command "_.undo" "_group") (setvar 'CLAYER "S - TEXT") (command "CMLEADERSTYLE" "NORMAL - SW") (setvar 'CMDECHO 1) (initcommandversion) (command ".MLeader" ins endPoint "") (while (> (getvar "CMDACTIVE") 0) (command PAUSE)) (setq mleaderObj (vlax-ename->vla-object (entlast))) (vla-put-TextString mleaderObj textString) (setvar 'CMDECHO 0) (command "CMLEADERSTYLE" "Normal") (command "_.LAYER" "_SET" curlay "") (command "_.undo" "_end") (setvar 'CMDECHO 1) (princ "MLeader with SW_LENGTH created.")) (alert "Insertion point not specified!"))) (alert "SW_LENGTH attribute not found!"))) (alert "Selected entity is not a block!")) (princ))
- 2 replies
-
- lisp
- dynamic block
-
(and 1 more)
Tagged with:
-
Suggestion for new Laptop
oddssatisfy replied to nidhi singhania's topic in Hardware & Operating Systems
I'm sure I'll get a variety of results but I need to buy a laptop, nothing special, no gaming, etc, and a reasonably fast budget of around £500, what do you recommend?