Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. BIGAL

    Block insert LISP

    The fix for the 1st and last arrow is easy, I look at the first point and is pline open if yes then just set angel_2 to the same ang as angel_1, Just add that extra line of code, same for last point, I just ignored and did not change. Same with your attributes how do you want to handle them so they are filled in correct.
  3. As a spline gives two answers the points answer and another with nodes. So any way if you explode the Mleader then you can get at the spline using this. Just need to check that the spline is last entity, tested in Bricscad. A disclaimer not sure if length is correct. I think it is short by length of arrow. Will try to find arrow length. Yep found it. (defun c:wow ( / plent pt len lenar) (setq plent (entsel "\nPick mleader ")) (setq lenar (cdr (assoc 140 (entget (car plent))))) (command "undo" "M") (command "explode" (car plent)) (setq ent (ssname (ssget "L") 0)) (setq len (getpropertyvalue ent "length")) (command "undo" "B") (alert (strcat "Total length is " (rtos (+ lenar len) 2 3))) (princ) ) (c:wow) I think you could do a "I want a length of 100 by drawing something close then move say arrow point till you get approx 100. Via lisp. It would be a two step process explode and move then undo and reset arrow head point.
  4. Yesterday
  5. This is very similar to the problem of draw a section marker, if your happy with a lisp answer can be done very easy, you have 4 choices or can be based on say 3 point pick. Would use say 2 blocks. a HOR and VER arrow. The other way may be to look at the angle the block is inserted and rotate the attribute about a centre justification, not sure if can do that in a dynamic block. will have a play. Some one else may jump in with a new dynamic block. Did something similar in another post that stretches the gap between the arrows.
  6. Ivan N

    Block insert LISP

    Worked perfect, the scale and the color thing is nice. Thank you very much, for you time and help.
  7. Ivan N

    Block insert LISP

    I tested it it work perfect. Only thing that is a little bit difficult is selection but I think I can take care of it. Thank you very mach you help me solve my problem.
  8. Ivan N

    Block insert LISP

    I tested it, its work fine. Only tune that needs is the take care of the first and the last. Both arrows has to point in one direction. Thank you very much for you time and effort.
  9. Tsuky

    Block insert LISP

    Try an another version (vl-load-com) (defun c:BLOCKINSERT ( / ss blkname acadObj doc mspace n dxf_ent vlaobj pr nb_e scl_blk pt lst_pt nbs ang1 ang2 blk lst itm) (setq ss (ssget '((0 . "*POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 112) (-4 . "NOT>"))) blkname "Stalb" ) (cond ((and ss (tblsearch "BLOCK" blkname)) (setq acadObj (vlax-get-acad-object) doc (vla-get-activedocument acadObj) mspace (vla-get-modelspace doc) ) (if (null (tblsearch "LAYER" "EL_стълб_НН")) (vlax-put (vla-add (vla-get-layers doc) "EL_стълб_НН") 'color 1) ) (repeat (setq n (sslength ss)) (setq dxf_ent (entget (setq ent (ssname ss (setq n (1- n))))) dxf_210 (cdr (assoc 210 dxf_ent)) lst_pt nil) (setq vlaobj (vlax-ename->vla-object ent) pr -1 ) (repeat (setq nb_e (if (zerop (vlax-get vlaobj 'Closed)) (1+ (fix (vlax-curve-getEndParam vlaobj))) (fix (vlax-curve-getEndParam vlaobj)))) (if (not scl_blk) (progn (initget 6) (setq scl_blk (getreal "\nBlock scale?<1>: ")))) (if (not scl_blk) (setq scl_blk 1.0)) (setq pt (vlax-curve-GetPointAtParam vlaobj (setq pr (1+ pr))) lst_pt (cons pt lst_pt) ) (setq nbs (1- (length lst_pt))) ) (foreach pto lst_pt (if (and (not (zerop nbs)) (not (eq (1+ nbs) (length lst_pt)))) (setq ang1 (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vlaobj nbs)) ang2 (+ pi (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vlaobj (1- nbs)))) ) (setq ang1 (if (not (zerop nbs)) (+ pi (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vlaobj (1- nbs)))) (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vlaobj nbs)) ) ang2 ang1 ) ) (if (and (zerop nbs) (not (zerop (vlax-get vlaobj 'Closed)))) (setq ang1 (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vlaobj nbs)) ang2 (+ pi (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vlaobj (length lst_pt)))) ) ) (if (and (eq (1+ nbs) (length lst_pt)) (not (zerop (vlax-get vlaobj 'Closed)))) (setq ang1 (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vlaobj nbs)) ) ) (setq nbs (1- nbs) blk (vla-InsertBlock mspace (vlax-3d-point pto) blkname scl_blk scl_blk scl_blk 0.0) ) (vlax-put blk 'Layer "EL_стълб_НН") (vlax-put blk 'Color 3) (setq lst (list (cons "Angel_1" ang1) (cons "Angel_2" ang2))) (foreach x (vlax-invoke blk 'getdynamicblockproperties) (if (setq itm (assoc (vla-get-propertyname x) lst)) (vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x)))) ) ) ) ) ) ) (prin1) )
  10. ml.LSP
  11. Anyone have any hints on how to get Spline Leader lengths? Ultimately, I am looking to make several already drawn spline leaders the same length.
  12. I want to create a dynamic block with 4 visual states. I want two text values to appear in each state but in different places in each state. If I understand correctly you cannot move an attribute from state to state. Fields would work but I have no way of knowing how many of these blocks may be needed in a particular drawing. If I copy the attributes from VS to VS when creating the block, they only are available in the first state. The other states report there is no editable attributes but if I edit the state they are there. Here is a diagram of the 4 visual states. (the red is not part of the block, just a separator) I had created a block with 8 attributes but users found it confusing or difficult to navigate. Is there a way to achieve this in a simpler/better fashion?
  13. try using nentsel (nested entity select) Tho you will have to select the attribute itself and not just the block. might want to add some error handling like check for attribute or text. then after you edit will have to regen to update the drawing. (defun c:foo () (while (setq sel (nentsel "\nSelect Block Attribute : ") (setq ename (car sel)) ;check if sel is attribute (setq edata (entget ename)) (setq tag (cdr (assoc 2 edata))) ; Attribute tag (setq val (cdr (assoc 1 edata))) ; Attribute value (princ (strcat "\nTag: " tag ", Value: " val)) ) (princ) )
  14. Hi @p7q, You can try with this several options from image below. From the last lines of code, you will get something like this. Try to play with this. Also, you can get from Lee Mac website about Attribute Functions. Best regards.
  15. LOL! Only for items that look difficult, or painful in lisp, where there’s a possible built in function. This drawing took 0.03673760 seconds to process. if the drawing is indeed correct, have a look here for how to run python https://github.com/CEXT-Dan/PyRx arc2.dwg
  16. Thanks, I replaced cadr with caddr, everything is fine.
  17. That sounds to me that you are trying to pull us to the dark side, sounds pretty tempting, would you walk us through?
  18. Agree with @GLAVCVS, with cadr you're getting the X coordinate, not Y coordinate.
  19. sorry ı dont know how to use this code in acad. I'm trying
  20. Is the coordinate order set to Y, X, Z? This could be the error. Try changing cadr to caddr in the line '(setq yval (cadr (assoc 10 edata)))'
  21. Did you have a look at my drawing? Python converted those arcs to ellipses in milliseconds. If you can run python, then it would be pretty easy to make it callable from lisp
  22. Hi everyone, I’m trying to get the text from an Attribute Definition (ATTDEF) inside a dynamic block using AutoLISP, and then change that text. Unfortunately, I haven’t been able to make it work. Here is what I tried: (defun getblockentities (blk / ent enx rtn) (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (setq enx (entget ent)) (if (= "INSERT" (cdr (assoc 0 enx))) (getblockentities (cdr (assoc 2 enx))) (progn (setq text (vlax-ename->vla-object ent)) (if (car text) (setq tlist (append tlist (list text))) ) ) ) ) ) ) And then I tried to collect attributes like this: (setq attlist (vlax-invoke textObj 'GetAttributes)) (foreach att attlist (if (not (eq (vla-get-tagstring att) nil)) (progn (setq text (vla-get-tagstring att)) (setq tlist (append tlist (list text))) ) ) ) But with this approach I couldn’t retrieve the attribute text. Is there another method to get (and later modify) the text string of an attribute inside a dynamic block? Thanks in advance for any guidance. edit: ı'm adding to dwg for trydinamic block text.dwg
  23. Unfortunately, I can’t share the LISP code itself, but I can explain the underlying logic.I use a helper function that processes each entity type. When it encounters a block, it gathers the block’s contents into a list; once the top-level selection is done, it feeds that list back into the same function to process all nested entities.”
  24. Last week
  25. Hello everyone Sorting by Y coordinate from bottom to top does not work. The numbers are not arranged in increasing order. How can this be fixed? (defun to3 (n) (setq str (rtos n 2 3)) (if (not (wcmatch str "*.*")) (setq str (strcat str ".000"))) (while (< (strlen (substr str (+ 2 (vl-string-search "." str)))) 3) (setq str (strcat str "0")) ) str ) (defun c:INCTEXT_Y (/ inc startval cnt sel txtlist sorted i ent edata yval newval strval) (setq inc 2.8) (setq startval 6.4) (setq cnt 1) (setq sel (ssget '((0 . "TEXT")))) (if sel (progn ;; Making a list: (entity, Y-coord) (setq txtlist nil) (setq i 0) (while (< i (sslength sel)) (setq ent (ssname sel i)) (setq edata (entget ent)) (setq yval (cadr (assoc 10 edata))) (setq txtlist (cons (list ent yval) txtlist)) (setq i (1+ i)) ) ;; Sorting by Y-coordinate from bottom to top ; (setq sorted (vl-sort txtlist '(lambda (a b) (> (cadr a) (cadr b))))) ; top to bottom? (setq sorted (vl-sort txtlist '(lambda (a b) (< (cadr a) (cadr b))))); bottom to top? ;; Changing values (foreach txt sorted (setq newval (+ startval (* cnt inc))) (setq strval (to3 newval)) (setq ent (car txt)) (setq edata (entget ent)) (setq edata (subst (cons 1 strval) (assoc 1 edata) edata)) (entmod edata) (setq cnt (1+ cnt)) ) (princ " The values of all selected texts are increased progressively.") ) (princ " Single texts are not selected.") ) (princ) )
  26. leonucadomi

    help with routines some don't work...

    THANKS
  27. If its part of your language and not some type of random ascii your using. with a fresh install of windows the language probably needs to be updated in the settings.
  28. Lee you are the bestest!
  1. Load more activity
×
×
  • Create New...