Jump to content

All Activity

This stream auto-updates

  1. Today
  2. 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
  3. Nikon

    Lisp divide pline

    You can just select a line... Without specifying points...
  4. Yesterday
  5. 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.
  6. 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))
  7. BIGAL

    Lisp divide pline

    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.
  8. 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) )
  9. 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))
  10. oddssatisfy

    Suggestion for new Laptop

    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?
  11. See this article from Autodesk. Why write code when you can use tools you already have? Welcome to the forum!
  12. Kris Malen

    Calculations with DCL, Lisp

    Thanks Dexus it works!!
  13. I had similiar request as OP and I confirm that this solution by Lee Mac works great in 2024.
  14. Noticed a type-o Steven (cons 78 (list "ANSI C (17.00 x 22.00 INCHES)" "ANSI B (22.00 x 17.00 INCHES)" )) to (cons 78 (list "ANSI C (17.00 x 22.00 INCHES)" "ANSI C (22.00 x 17.00 INCHES)" ))
  15. Might try this APP from Terry Dotson of DotSoft...DwgSearch | AutoCAD | Autodesk App Store
  16. To the big-hearted, friendly programming professionals who have contributed so far: Plans are to continue the progress on this effort once several unplanned events clear. Please stay tuned! Yours, C.
  17. CyberAngel

    How to close weld gap in AutoCad 3D

    This is just spitballing, but could you draw a 3D polyline between the edges on one side and another one on the other side, then use LOFT to connect them? Or are these edges arbitrary, meaning you want to automate the process? Or is it more complicated than I suppose (most likely option)?
  18. @BIGAL Thank you, I do not know lisp that much, do you have a complete lisp to do that. Maybe something like after pressing DONE will transfer the results to the clipboard or Excel
  19. The image is very confusing. You say you're trying to weld a piece of angle iron to a plate but I see 5 different colors. So where is the angle iron and where is the plate? And why is the weld size different? I just don't understand what I'm looking at.
  20. thank you Bigal and SLW201. I have already all the blocks of bolts and nuts. And i want to use Lisp. You helped me all. I saw the block counter of Lee Mac. is't a perfect routine. Very Nice program. I'v been helped greatly en thanks all. regards PatjeCad.
  21. Bolts come in standard lengths unless you are custom making them. I just have a set of blocks for each bolt length for each type and size (really not a lot of different ones I use so not a huge amount), each block has a different name so easy to count them. (I plan to make some dynamic blocks eventually) Nuts are separate and so are washers, so I get a count on those as well. Lot's of LISPs etc. around to create a list (BOM) for block names. Easy to do the same with a dynamic block with Visibility States, etc. to get a count. Just for a start... Dynamic Block Counter | Lee Mac Programming (lee-mac.com) Dynamic Block Functions | Lee Mac Programming (lee-mac.com) Maybe have an attribute added with information? Connecting attribute values to visibility states for dynamic blocks in AutoCAD (autodesk.com)
  22. dexus

    Calculations with DCL, Lisp

    The problem isn't the way its coded, or with using the temp folder. I think its a nice way of making a dialog tbh. The problem is here: (cond [...] ( (set_tile "res" (rtos (- x y) 2))) ( (set_tile "res2" (rtos (- x z) 2))) ) The first one returns true, and stops the cond. If you want two actions, you want to put them together in a cond-item. Like so: (cond [...] (t (set_tile "res" (rtos (- x y) 2)) (set_tile "res2" (rtos (- x z) 2)) ) )
  23. Autolisp that can calculate the quantity of steel bars as it placed on the plan of reinforcement read the annotations from an existing drawing and makes a summary table out of it. screen-20240517-001606.mp4
  24. Do you have all updates to AutoCAD? Can you do a "Reset to Defaults"? How to reset AutoCAD to defaults (autodesk.com) Though you might need to run a repair or reinstall. How to repair or reinstall an AutoCAD installation (autodesk.com)
  25. You're right mhupp, the mapss function wouldn't give an error in the "test command" pkenewell posted, but we do want these functions to work in most situations without throwing unexpected errors. Probably good to check if ss is really a pickset as well: (defun mapss (ss func) (if (= 'PICKSET (type ss)) (mapcar func (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)) ) ) ) ) Just to note, it is best to only use the mapss function when you need the output of the functions to be returned in a list. Otherwise your foreach loop or the foreach-ss function posted earlier would be preferable.
  1. Load more activity
×
×
  • Create New...