How to add a Base Point to MSWEEP LISP?

How to add a Base Point to MSWEEP LISP?

LeoManu
Enthusiast Enthusiast
145 Views
4 Replies
Message 1 of 5

How to add a Base Point to MSWEEP LISP?

LeoManu
Enthusiast
Enthusiast

Hi,

I am using the MSWEEP AutoLISP routine from this Autodesk post:

How to sweep solid along multiple paths in AutoCAD

The routine works fine for sweeping a solid along multiple paths, but I would like to modify it to add a Base Point option, similar to the standard AutoCAD SWEEP command.

I would like to be able to select a base point on the profile before selecting the paths, so that the profile is positioned correctly when it is swept.

Does anyone know what needs to be added or changed in the LISP code to make this possible?

Thanks!

0 Likes
Accepted solutions (2)
146 Views
4 Replies
Replies (4)
Message 2 of 5

Sea-Haven
Mentor
Mentor
Accepted solution

If you look at the sweep options one of them is Base point. if you just pick object and then Sweep it looks like it just uses a centroid of object, so you may need to add that option in the lisp. The other way is to use Rotate3d about a control point so orientation is maintained then use extrude. Just be aware using base point need to draw object in correct orientation.

Base point of object in image is the "V" 

SeaHaven_1-1787538993874.png

 

Give this a try.

(defun c:msweep ()
  (setq oldsnap (getvar 'osmode))
  (setvar 'osmode 23) ; mid end cen quad
  (setq delobjvar (getvar "delobj"))
  
  (setq prf (car (entsel "\nPick profile to sweep: ")))
  (setq bprf (getpoint "\nPick base point "))
  
  (princ "\nSelect paths to sweep along: \n")
  (setq mpth (ssget))
  
  (if (= mpth nil)(progn (alert "No paths selected \nwill now exit try again")))
  
  (princ (sslength mpth))
  (princ " - Paths selected.")
  (setvar "delobj" 0)
  
  (setq cntr 0)
  (while (< cntr (sslength mpth))
    (setq sweeppath (ssname mpth cntr))
    (command "sweep" prf "" "B" bprf sweeppath)
    (setq cntr (+ cntr 1))
  )
  
  (princ (strcat "\n" "objects created using sweep command " (rtos cntr 2 0)))
  (setvar "delobj" delobjvar)
  (princ)
)
(c:msweep)

 

0 Likes
Message 3 of 5

lauri_barnhart
Autodesk
Autodesk

Hello, @LeoManu.

 

Hope you are well. Checking in to see if you saw the information provided by Sea-Haven. Did the information help clarify your question and provide a solution? If it did, please consider clicking on the 'Accept Solution' button. If you still have questions, please update here.

 

Best,


Lauri | Community Manager
0 Likes
Message 4 of 5

LeoManu
Enthusiast
Enthusiast

Hi,

Sorry for the delay. I just tested the LISP and it works well, but I have one issue.

I attached an example. When I run MSWEEP on a W profile (rotated vertically from the top), on some lines it creates the sweep below the path (which is what I want), but on other lines it creates it above the path.

Why does this happen?

Other than that, it works great! Thank you very much for your help.

0 Likes
Message 5 of 5

Sea-Haven
Mentor
Mentor
Accepted solution

As I suggested earlier for me I would tend to use the rotate3d function, you take a shape place on the start of the path, then stand it up vertically and rotate to be at 90 degrees to the path. This is an example take shape drawn in World, rotate to align with path, move based on correct base point, I used m2p picked center of flanges, then end of path, rotate3d so stand shape vertical, then did Extrude using path. It could be a lisp. 

 

SeaHaven_0-1787877119763.png

Thought straight away lines or plines on angle but flat no 3d. For say UB would get mid point flanges, then mid top and get angle, then realign to match angle of line etc and stand up vertical.  

 

This is line only as a test if happy will add more objects, The paths can be at angles.

(defun c:dbeam ( / oldang oldang pt1 pt2 pt3 pt4 ang1 ang2 ent1 ent2 )
(setq oldang (getvar 'aunits))
(setvar 'aunits 3)
(setq oldsnap (getvar 'osmode))

(setq pt1 (getpoint "\nPick base point on object "))
(setq pt2 (getpoint "\nPick 2nd point for alignment "))

(setq ang1 (angle pt1 pt2))
(setq ent1 (ssname (ssget pt2) 0))
(setvar 'osmode 1)

(setq ent2 (car (entsel "\nPick path near start end ")))
(setq entg (entget ent2))
(setq pt3 (cdr (assoc 10 entg)))
(setq pt4 (cdr (assoc 11 entg)))
(setq ang2 (angle Pt3 pt4))

(setvar 'osmode 0)
(command "move" ent1 "" pt1 pt3)
(command "rotate" ent1 "" pt3 (- ang2 ang1))
(command "ucs" "OB" ent2 )
(command "rotate3d" ent1 "" "Y" "0,0,0" (/ pi 2.))
(command "UCS" "W")
(command "extrude" ent1 "" "path" ent2)

(setvar 'aunits oldang)
(setvar 'osmode oldsnap)
(princ)
)
(c:dbeam)

 

0 Likes