does this exist in autocad?

does this exist in autocad?

jorgearone_inssitu
Enthusiast Enthusiast
636 Views
7 Replies
Message 1 of 8

does this exist in autocad?

jorgearone_inssitu
Enthusiast
Enthusiast

Hi, everyone

I would like to know if this is possible in Autocad
I'm on the same layer (Those are all the elements of the layer)
1. Is it possible to assign each element a factor (similar to what is in red)
2. If point 1 is possible, using a lisp to be able to add each polyline length multiplied with its factor, from all layer.

 

jorgearone_inssitu_0-1691326941823.png

jorgearone_inssitu_1-1691327638956.png

 

 

 

 

 

637 Views
7 Replies
Replies (7)
Message 2 of 8

calderg1000
Mentor
Mentor

Regards @jorgearone_inssitu 

Try this code, Select 2 by 2 text and Lwpolyline->click D, successively. Then click D, to finish. View output on the command line.

(defun c:sumpt (/ s i sn l nx lpx pr lpf prt)
  (princ "\nSelect Text and Lwpolyline 2 by 2...: ")
  (while
    (setq s (ssget '((0 . "*text,lwpolyline"))))
     (setq lpx '()
     )
     (repeat
       (setq i (sslength s))
        (setq sn (vlax-ename->vla-object (ssname s (setq i (1- i)))))
        (if (= (vla-get-objectname sn) "AcDbPolyline")
          (progn
            (setq l   (vla-get-length sn)
                  lpx (cons l lpx)
            )
          )
          (progn
            (setq nx  (vla-get-textstring sn)
                  nx  (atof nx)
                  lpx (cons nx lpx)
            )
          )
        )
     )
     (setq pr (apply '* lpx))
     (princ pr)
     (setq lpf (cons pr lpf))
  )
  (setq prt (apply '+ lpf))
  (princ (strcat "Total Sum: " (rtos prt 2 3)))
  (princ)
)

Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 3 of 8

Sea-Haven
Mentor
Mentor

Another suggestion is select the text then look around it for a pline. Then get length*factor adding as you go.

 

There is many, many examples of get text and look for an object. The method is say to make a little box based on text point and see if it crosses a pline. I uses ssget "F" listofpointspline plinefilter.

0 Likes
Message 4 of 8

jorgearone_inssitu
Enthusiast
Enthusiast

Thanks for the code, if it's very useful and practical, I'm going to use it, only this would be done manually.
My question is more about whether it is possible to assign or define a factor to an element (such as the polyline) intrinsically, by default, or indirectly. In such a way that the lisp can do the mathematical operation automatically, without having to be picking points in the plane.

0 Likes
Message 5 of 8

jorgearone_inssitu
Enthusiast
Enthusiast
Thanks for the suggestion,
Do you think you can give an example?

You say that the lines could be crossed with the text?
And from there the code could intercept and identify them.
0 Likes
Message 6 of 8

calderg1000
Mentor
Mentor

Regards @jorgearone_inssitu 

Yes of course, with XDATA, a factor can be attached to the polyline, entering a real number and it can be recovered with XDLIST. Then only the polylines would be selected and the product would be done internally automatically. With a little time I will try again later.


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 7 of 8

jorgearone_inssitu
Enthusiast
Enthusiast

Please thank you very much.

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

This is an example of get 1 pline next to a text. you would get all text and run in a loop getting a pline then the length of the pline then * (atof txt) to get the answer you want. The 10 in the polar command is a distance change to suit.

 

(setq ent (entsel "\nPick a text object "))
(setq pt (cdr (assoc 10 (entget (car ent)))))
(setq pt1 (polar pt (* pi 0.25) 10))
(setq pt2 (polar pt (* pi 0.75) 10))
(setq pt3 (polar pt (* pi 1.25) 10))
(setq pt4 (polar pt (* pi 1.75) 10)) ; 4 point box
(setq lst '()) ; empty list
(setq lst (cons pt1 lst))
(setq lst (cons pt2 lst))
(setq lst (cons pt3 lst))
(setq lst (cons pt3 lst))
(setq lst (cons pt1 lst)) ; close box
(setq ss (ssget "F" lst '((0 . "LWPOLYLINE")))) ; look for a pline
0 Likes