LISP that converts 3D polyline to solid

LISP that converts 3D polyline to solid

LukasA-HAK
Enthusiast Enthusiast
10,983 Views
48 Replies
Message 1 of 49

LISP that converts 3D polyline to solid

LukasA-HAK
Enthusiast
Enthusiast

Hi,
I am a surveyor at a pipe construction company.
The preliminary design requires data from pipeline traces of other companies that are already in the ground with their pipeline traces
Test trenches must be dug for this purpose.
The engineering firm wants this data to be supplied in autocad solids 3D. With the pipe data in the layer name.
The work process for this is now:
Create layer name. Place circle with diameter pipe on 3D polyline. Apply command sweep along path. Then I still have to move the solid because the top of the pipes have been measured.
This must be done manually for each pipe. Sometimes I'm busy for days.

Isn't there an autocad lisp routine that can automate this work??
It would be nice if this lisp could retrieve the diameter from, say, the layer name.

0 Likes
Accepted solutions (3)
10,984 Views
48 Replies
Replies (48)
Message 21 of 49

LukasA-HAK
Enthusiast
Enthusiast

Hi,
Here are 2 GPS files of a measured test trench measured with GPS.
The first is the START file as it comes out of the GPS device.
The second is the converted measurement file using ВeekeeCZ's awesome LIPS routine.

0 Likes
Message 22 of 49

LukasA-HAK
Enthusiast
Enthusiast

Hello,
Here are 2 GPS files of a measured test trench measured with GPS.
The first is the START file as it comes out of the GPS device.
The second is the converted measurement file using ВeekeeCZ's sophisticated LIPS routine

0 Likes
Message 23 of 49

LukasA-HAK
Enthusiast
Enthusiast

Is the second part also possible to make?

0 Likes
Message 24 of 49

ВeekeeCZ
Consultant
Consultant

@LukasA-HAK wrote:

This works great. How did you do this??


 

(foreach point from all-points-sorted-incrementally-by-no
   (if 	(and 	this point no is 1+ previous point no
		this point desc is the same or same+suffix as the previous point desc
		angle between current and previous segment is more than 88°)
         then add this point to the previous one to create a line, desc of 1st one use as layer name
	 else start a new line.

  (if 	line has only one point 
	then add 2nd pnt with 1st+(dx=dy=0.02) and color them.

 

Message 25 of 49

LukasA-HAK
Enthusiast
Enthusiast

Should this be added to the code?

0 Likes
Message 26 of 49

ВeekeeCZ
Consultant
Consultant

Well, I thought that you want to know how the program works. So I've tried to explain the main algorithm but I see... still too much. My bad. I've better keep silence.

0 Likes
Message 27 of 49

LukasA-HAK
Enthusiast
Enthusiast

I thought so
I try to understand Autocad Lisp. I read about it. I can't say I think it's simple.

0 Likes
Message 28 of 49

Sea-Haven
Mentor
Mentor
Accepted solution

Can you supply the GPS data file not a dwg I still think better to string based on the field GPS survey, so need to see what is in a file. Spent last 40 years working with Field surveys and feature coding.

0 Likes
Message 29 of 49

LukasA-HAK
Enthusiast
Enthusiast
I regret that I only see how powerful LISP is after 23 years
0 Likes
Message 30 of 49

LukasA-HAK
Enthusiast
Enthusiast

Hi,
These are the raw measurement data of the test trench in question.
The names are in Dutch, but I don't think that will matter for the processing of the data.
However, automation has not yet been taken into account during the measurement.
It might be an idea if I create a text file using data extraction.

0 Likes
Message 31 of 49

LukasA-HAK
Enthusiast
Enthusiast

Hi,
This is the data as that data extraction creates. A csv file is also possible. This is a simplified file of the same test trench

0 Likes
Message 32 of 49

LukasA-HAK
Enthusiast
Enthusiast

Hi, this is the csv file of the measured points

0 Likes
Message 33 of 49

Sea-Haven
Mentor
Mentor

Thank you for the files I will try to get a similar file for a dwg so can show how stringing works, I think can do something with what you have. Based on codes as stringing.

 

Can you PM me your email as I think will have a bit of back and forth.

0 Likes
Message 34 of 49

LukasA-HAK
Enthusiast
Enthusiast

Thank you.

I will try to understand lisp asap

My email adress is [email protected]

0 Likes
Message 35 of 49

LukasA-HAK
Enthusiast
Enthusiast

It is possible that e-mail is initially blocked by the system.

0 Likes
Message 36 of 49

Sea-Haven
Mentor
Mentor

Edit your post better to not post emails in public you can use private mail for stuff like that. I have it now.

0 Likes
Message 37 of 49

ВeekeeCZ
Consultant
Consultant
Accepted solution

@LukasA-HAK wrote:

Is the second part also possible to make?


 

Not sure whether you still follow this route but since is quite simple here you go. 

 

You need to select 3dpolys in *#mm* layers where # is considered a diameter.

The current dwg is probably in mm, so either scale the drawing to m or change (/ d 2.) to (/ d 2000.) in the code.

Remove the semicolon from (entdel e) line if you want to 3dpolys be removed.

 

(vl-load-com)

(defun c:sweepalong ( / *error* lay doc i e l d x)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if lay (setvar 'clayer lay))
    (vla-endundomark doc)
    (princ))
  
  (setq lay (getvar 'clayer)
	doc (vla-get-activedocument (vlax-get-acad-object)))
  
  (if (and (setq s (ssget '((0 . "POLYLINE") (8 . "*#mm*"))))
	   (not (vla-startundomark doc)))
    
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    l (cdr (assoc 8 (entget e)))
	    d (atof (substr l (1+ (strlen (vl-string-right-trim "0123456789." (substr l 1 (vl-string-search "mm" l))))))))
      
      (setq x (entmakex (list '(0 . "CIRCLE") '(10 0 0 0) (cons 8 l) (cons 40 (/ d 2.)))))
      (setvar 'clayer l)
      (command "_.move" e "" "_d" "_non" (list 0 0 (/ d -2.))
	       "_.sweep" x "" e "")
      (entdel x)
      ;(entdel e)
      ))
  
  (*error* "end")
  )

 

0 Likes
Message 38 of 49

LukasA-HAK
Enthusiast
Enthusiast

I have tested the program.
We work in metres. I modified the program and it works great!
Because we also work with another measurement system, I also want to continue with the string solution from Sea-Haven.

0 Likes
Message 39 of 49

LukasA-HAK
Enthusiast
Enthusiast

Hi BeekeCZ, when trying to run the program to other measurement files it gives the following  error: Error: ADS request error.

Ik don`t get where this error comes from...

What is the minimum information the LISP code needs to have?

0 Likes
Message 40 of 49

LukasA-HAK
Enthusiast
Enthusiast

About the connectpoints lisp:

I think it works now.

I looked into the test file.

I think you made the following adjustments 
- First insunits 0; insunitsdeftarget 0;insunitsdefsource feet) units to surveyor settings; (grads; direction north; clockwise)
- Layer created layer1 and made current.
- Then Wblock > autocad 2007 file,

0 Likes