Jump to content

Recommended Posts

Posted (edited)

Hello guys,

I couldn't add the length of the line to csv.

file.jpg

I want to extract like this:

K5172, 60/60, 720

 

 

Can anyone help me with this code?

 

(defun c:rp2 (/ ent1 ent2 ent3 len fh fname)
 (setq fname (strcat (getvar "dwgprefix") (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4 )) ".csv")
          fh (open fname "a")
 )
 (command "_-LAYER" "_M" "SELECTED" "_C" 2 "" "") 
 (while (setq en1 (car (entsel "\nPick Text: ")))
   (setq ent1  (entget en1)
         ent1  (subst (cons 8 "SELECTED") (assoc 8 ent1) ent1)
   )
   (entmod ent1) 
   (setq en2 (car (entsel "\nPick another text: ")))
   (setq ent2  (entget en2)
         ent2  (subst (cons 8 "SELECTED") (assoc 8 ent2) ent2)
   )   
   (entmod ent2)
(setq en3 (car (entsel "\nPick the line: ")))
   (setq ent3  (entget en3) 

len (distance
(cdr (assoc 10 ent3)) (cdr (assoc 11 ent3)) ) 
)


    
   (write-line (strcat (cdr (assoc 1 ent1)) ", "  (cdr (assoc 1 ent2))) fh)
 )
 (princ (strcat "\nFile: " fname " Created."))                                               
 (close fh)
)

Edited by Avcit
Posted

Add this part:

(write-line (strcat (cdr (assoc 1 ent1)) ", "  (cdr (assoc 1 ent2)) [color="blue"]", " (rtos len 2 4)[/color]) fh)

Posted

Thanks. It works :)

 

How can I define length and area for polyline?

 

I just want to click just one polyline and it will export its length and area to csv. :unsure:

Posted (edited)
Thanks. It works :)

You are welcome. :)

 

Thanks. It works :)

 

How can I define length and area for polyline?

 

I just want to click just one polyline and it will export its length and area to csv. :unsure:

 

Try the following and hope you are able to add it to your codes:

 

(if (and (setq s (car (entsel "\nSelect Polyline :")))
        (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
        )
   (setq lgth (vlax-curve-getdistatparam s (vlax-curve-getendparam s))
         area (vlax-curve-getarea s)
         )
 (princ "\nNull selection or object is not a LWpolyline !")
 )

Edited by Tharwat
Posted

It gives an error.

Pick Text:
Pick another text:
Pick the line:
Select Polyline :; error: no function definition: [color="blue"]VLAX-CURVE-GETENDPOINT[/color]

 

I don't need to "if loop", because all my polylines are closed. (Shown in picture):unsure: kolon.jpg

Posted

Just add the following function to load the VL* functions library at the top or at the end of your routine.

(vl-load-com)

Posted

(vl-load-com)

 

Thank you for your interest. It works except length. It gives the length of closed polyline 0.0000 .

I need a length code for closed polyline :cry:

Posted
Thanks.

 

You are a great coder :)

 

You are most welcome.

 

It is nice of you to say that :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...