LISP to automatically sweep circles along closest 3D polyline

LISP to automatically sweep circles along closest 3D polyline

Anonymous
Not applicable
2,833 Views
16 Replies
Message 1 of 17

LISP to automatically sweep circles along closest 3D polyline

Anonymous
Not applicable

Hello,

 

I'm a Surveyor and we measure a lot of cables where we give in the diameter of the cable as an attribute.

When we load our data in, I've managed to create a circle at the start of each 3D polyline with the right diameter via point groups(the diameter is in the raw description of the point, "CODE DIAMETER").

The problem is that we still have to manually sweep all the circles. So I'm searching for a lisp that sweeps all the circles along the nearest 3D polyline and that it gets sweeped with basepoint top of the circle (because we meausure the top side of the cables).

 

Thanks ahead!

 

Hannes

0 Likes
Accepted solutions (1)
2,834 Views
16 Replies
Replies (16)
Message 2 of 17

john.uhden
Mentor
Mentor

Can you provide us an image or DWG of your "sweeping?"

From what in the drawing to we determine the diameter, a Cogo point, a point with description attribute, or what?

I am presuming that the 3D poly is following a path of survey points.

Are the circles to be drawn at an interval or just at every vertex?

Might the diameter change at any vertex, and if so how do you want the change displayed?

Actually it sounds like your 3D polyline might be in profile.  If so, and you have vertical exaggeration, might you want to draw ellipses instead of circles?  But you wouldn't have survey points in a profile, would you?

John F. Uhden

0 Likes
Message 3 of 17

Anonymous
Not applicable

See attachment.

The circles are already drawn everywhere as blocks. Now we just explode all these and sweep them manually along every 3D polyline.

What we need is a lisp that automates all the manually selecting and sweeping of the circles.

0 Likes
Message 4 of 17

john.uhden
Mentor
Mentor

My imagination must be lacking today.  I am not really seeing any sweeping. It appears that the circles you have are only at the north end of a few lines, each of which has Xs at its ends.  Are the lines actually the 3D polylines of which you speak?

Why would you create blocks only to later have to explode them?

John F. Uhden

0 Likes
Message 5 of 17

Anonymous
Not applicable

I could only create blocks via point groups. There are only circles where the surveyor puts in a diameter with a measured point (1 diameter per cable). 

There's nothing sweeped yet, this is the data that comes into civil 3d. I just need a lisp that sweeps all the circles in the drawing so we don't have to do it manually.

0 Likes
Message 6 of 17

john.uhden
Mentor
Mentor

Okay, so it's a "limitation" of C3D to automate the insertion of blocks only at survey points having certain descriptors.

You'll still have to show me a picture of "sweeping."  Though I have plenty of civil/survey experience, to me the term applies to only the porch or garage.  I would rather use the gas powered blower anyway.

John F. Uhden

0 Likes
Message 7 of 17

Anonymous
Not applicable

See attachment.

The command "SWEEP" is used to sweep the circles along the 3d polyline to create 3d cables

0 Likes
Message 8 of 17

Ranjit_Singh
Advisor
Advisor

Maybe post a simple dwg file with a few cogo points and the right point style. That way we can see the circles, how close they are to the 3d plines, etc.

0 Likes
Message 9 of 17

john.uhden
Mentor
Mentor

Is that picture taken from a 3D view?  The circles appear elliptical.  Or maybe it's just a 2D emulation of an extrusion?

John F. Uhden

0 Likes
Message 10 of 17

ActivistInvestor
Mentor
Mentor

@Anonymous wrote:

See attachment.

The command "SWEEP" is used to sweep the circles along the 3d polyline to create 3d cables


Your image shows cylinders, that could have been created via either SWEEP or EXTRUDE. If it was SWEEP, then the 3D polylines could have had only one segment each. Automating SWEEP is fairly-simple, but to do that you need to know what you start with and the desired end result.

 

The best way to convey it here is to post a DWG file that has both the 'before' and 'after' conditions. Sweeping a circle along a path requires the circle to be oriented such that the normal is tangent to the path at the point where the center is on the path.

0 Likes
Message 11 of 17

Anonymous
Not applicable

See attachments of before and after.

The insertion point of the circles is placed on the measurd point. This can be changed (just a matter of changing the blocks). They are set up like this for the moment because it was easier to sweep them (strangely it worked better to put the insertion point at the low point of the circle to sweep them as basepoint with the high point of the circle).

0 Likes
Message 12 of 17

Anonymous
Not applicable

Btw, the circles aren't always at the top of the line (but at the point where the Surveyor put in a diameter).

0 Likes
Message 13 of 17

ActivistInvestor
Mentor
Mentor

@Anonymous wrote:

See attachments of before and after.

The insertion point of the circles is placed on the measurd point. This can be changed (just a matter of changing the blocks). They are set up like this for the moment because it was easier to sweep them (strangely it worked better to put the insertion point at the low point of the circle to sweep them as basepoint with the high point of the circle).


I looked at both files but can't seem to correlate each before/after case (the after file has more objects, and none of them seem to resemble the objects in the before file). 

 

Sweeping a circle along a 3DPOLY is fairly-simple, if the 3DPOLY represents the center-line of the figure, then you would first set the current UCS origin to the start of the polyline, and set the UCS Z axis so that the end of the first polyline segment lies on it, then draw the circle with its center at UCS 0,0,0, and issue the SWEEP command and select the circle profile and the polyline path and yer done.

0 Likes
Message 14 of 17

Anonymous
Not applicable

Made some mistakes with the before and after files, in attachment the new, correct ones.

 

BEFORE file contains:

 

 

- blocks in the form of circles (these need to be exploded and sweeped along their 3D polyline)

- blocks in the form of markers (these are just the measured points, nothing needs to happen with them).

-3D polylines

 

AFTER file contains:

 

- blocks in the form of markers (nothing happened with them)

- 3D solids (the exploded circle blocks along their 3D polyline).

 

If this could be automated with a lisp, it would save me a lot of work. The 3DPOLY represent the top-line of the sweep.

 

0 Likes
Message 15 of 17

Ranjit_Singh
Advisor
Advisor

Try below code. You may have to work in batches as shown.

(defun c:somefunc  (/ 3p blset ctr delobj etdata pt val ss1)
 (setq curdelobj (getvar 'delobj))
 (setvar 'delobj 0)
 (and (setq ctr 0
            ss1 (ssget '((0 . "polyline"))))
      (repeat (sslength ss1)
       (and (or (and (setq val   "sp"
                           blset (nentselp (setq pt (vlax-curve-getstartpoint (setq 3p (ssname ss1 ctr))))))
                     (> (length blset) 2))
                (setq val   "ep"
                      blset (nentselp (setq pt (vlax-curve-getendpoint (setq 3p (ssname ss1 ctr)))))))
            (if (null (wcmatch (cdr (assoc 2 (entget (car (last blset))))) "dia*"))
             (setq blset (if (= val "ep")
                          (nentselp (setq pt (vlax-curve-getstartpoint (setq 3p (ssname ss1 ctr)))))
                          (nentselp (setq pt (vlax-curve-getendpoint (setq 3p (ssname ss1 ctr)))))))
             t)
            (entmod
             (subst (mapcar '+
                            (assoc 10
                                   (setq etdata (entmod (subst (cons 10 (cadr blset))
                                                               (assoc 10 (setq etdata (entget (entmakex (entget (car blset))))))
                                                               etdata))))
                            (list 0 0 (cdr (assoc 40 etdata)) 0))
                    (assoc 10 etdata)
                    etdata))
            (vl-cmdf "._sweep" (entlast) "" "_b" pt 3p))
       (setq ctr (1+ ctr))))
 (setvar 'delobj curdelobj)
 (princ))

sweep_cable.gif

 

0 Likes
Message 16 of 17

Anonymous
Not applicable

This works perfect! Thanks! Could you make it so that the sweeped solid is in the same layer as the original 3DPOLY?

0 Likes
Message 17 of 17

Ranjit_Singh
Advisor
Advisor
Accepted solution

OK. See below code.

(defun c:somefunc  (/ 3p blset ctr curlayer curdelobj etdata pt val ss1)
 (setq curdelobj (getvar 'delobj))
 (setvar 'delobj 0)
 (setq curlayer (getvar 'clayer))
 (and (setq ctr 0
            ss1 (ssget '((0 . "polyline"))))
      (repeat (sslength ss1)
       (and (or (and (setq val   "sp"
                           blset (nentselp (setq pt (vlax-curve-getstartpoint (setq 3p (ssname ss1 ctr))))))
                     (> (length blset) 2))
                (setq val   "ep"
                      blset (nentselp (setq pt (vlax-curve-getendpoint (setq 3p (ssname ss1 ctr)))))))
            (if (null (wcmatch (cdr (assoc 2 (entget (car (last blset))))) "dia*"))
             (setq blset (if (= val "ep")
                          (nentselp (setq pt (vlax-curve-getstartpoint (setq 3p (ssname ss1 ctr)))))
                          (nentselp (setq pt (vlax-curve-getendpoint (setq 3p (ssname ss1 ctr)))))))
             t)
            (entmod
             (subst (mapcar '+
                            (assoc 10
                                   (setq etdata (entmod (subst (cons 10 (cadr blset))
                                                               (assoc 10 (setq etdata (entget (entmakex (entget (car blset))))))
                                                               etdata))))
                            (list 0 0 (cdr (assoc 40 etdata)) 0))
                    (assoc 10 etdata)
                    etdata))
            (setvar 'clayer (cdr (assoc 8 (entget 3p))))
            (vl-cmdf "._sweep" (entlast) "" "_b" pt 3p))
       (setq ctr (1+ ctr))))
 (setvar 'delobj curdelobj)
 (setvar 'clayer curlayer)
 (princ))

sweep_cable_2.gif