Jump to content

Recommended Posts

Posted

Hi CADTutor forumers, I have tried to create a track by using sweep function. It almost achieve what I want but the sweep altered the angle of the track. Please shed some light on how to solve this issue. Thank you.

image.png.cef9c2697101548c0fadbd6d06e9a03a.png

Hotwheel Track 3.dwg

Posted

Are you doing this with a LISP?

 

You posted this in the AutoLISP, Visual LISP & DCL Forum.

Posted
1 hour ago, SLW210 said:

Are you doing this with a LISP?

 

You posted this in the AutoLISP, Visual LISP & DCL Forum.

 

Hi SLW210, I am not doing it with LISP. I think I am posting in a wrong forum category. I am so sorry about it.

Posted

No problem, I have moved your thread to the AutoCAD 3D Modelling & Rendering Forum.

 

Can you provide a drawing from before you did the sweep?

 

Can you provide the exact steps you took, what method did you use to construct the sweep, path?

 

If so, I need the path.

 

I guess you are just making a basic loop in a Hot Wheel track, or is this just an example?

Posted

My guess is that the path winds up being shorter on the odd side, so the curve solution has no choice but to constrict the shape. The easiest solution, of course, is to redefine the path.

 

You may need to break the shape into different segments. You may need to use a different command, or a combination of commands, to get what you want. Modeling often takes some experimentation.

Posted

I have found that the sweep command provides very limited control of the twist in sweeping a cross section along a spline.  To get some local control on twist I took the strategy of using loft  to create the "sweep" effect. The following  LISP program is a work-in-progress (i.e., still buggy)   to provide an initial placement of the sections prior to using loft.

 

Here's the workflow to use it.

1. Create a block of the cross section.  The profile should be a single polyline with the block's base point on the centerline.  The z axis of the block will be tangent to the spline.

2. Execute the program and specify the number of loft sections you want, the name of the block, the start twist angle, and the total twist from the start of the spline to its end.

 

After running the program you can individually rotate section as desired.  Just use the UCS OB command and the rotate command to rotate the block about its Z axis to the orientation you want.

 

Explode all the block after getting the their rotations as needed and then give the loft  command.

 

Note, to get the twist reference point the program takes the cross product of the first derivatve ( the slope) and the second derivative (the change in the change of the slope). Where the curvature of the spline is fairly flat this can yield undersirable results. 

 

The program needs some additional debugging but I have found it useful as is.

 

Here are the results with 15 sections and a start twist angle of 0 and total twist angle of 0.  Note that the first section needs to be rotated by about 90° and the second by about -135°

image.png.13cb774c68580272fef76cc27a46c367.png

Here's the results after the two rotations.

image.png.2961a335a2ae354331d09ee22205263a.png

The results after exploding the blocks and lofting.

image.png.2fab14b647a0e79d05f9911182730d16.png

 

(defun C:test (/ nsec blockname twist tottwist path inc n osm par der1
	 der2 p p1 p2 vy vz vx p3)
	       ;  draft version
;  Adds blocks along a spline.  The user specifies the number of blocks and
; the total amount of twist over the length of the spline.   The Z axis of the block
; is tangent to the spline.  
; LRM 5/1/2023 revised 6/4/2024  
(command "ucs" "w")
(setvar 'osmode 0)
(setq nsec (getint "\nEnter number of sections: "))
(setq nsec (- nsec 1))  
(setq blockname (getstring "\nEnter block name: "))
(setq twist (getreal "\nEnter start twist angle: "))
(setq tottwist (getreal "\nENter total twist start to end: "))  
(setq
  path (car (entsel))
  inc  (/ (vlax-curve-getEndParam path) nsec)
  n    0
  osm  (getvar 'osmode)
)
(setvar "cmdecho" 0)
(repeat	(+ nsec 1)
  (setq par (* inc n))
  (setq	der1 (vlax-curve-getfirstDeriv path par)
	der2 (vlax-curve-getSecondDeriv path par)
	p    (vlax-curve-getPointAtParam path par)
  )
  (setq p1 (mapcar '+ p (unitv (cross der1 der2))))
  (setq p2 (mapcar '+ p (unitv der1)))
  (setq vy (unitv (mapcar '- p1 p)))
  (setq vz (unitv (mapcar '- p2 p)))
  (setq vx (unitv (cross vy vz)))
  (setq p3 (mapcar '- p vx))
(command "_point" "_non" p)
(command "_point" "_non" p2)
(command "_point" "_non" p3)
  (command "-insert" blockname '(0 0 0) 1 1 0)
  (command "_align" "last" "" '(0 0 0) p '(1 0 0) p1 '(0 0 -1) p2 "n")
  (if (> (abs twist) 0.00001)
   (command "rotate3d" "last" "" "2" p p2 twist)
  )
  (setq twist (- twist (/ tottwist nsec)))
  (setq n (1+ n))
)					; end repeat
(setvar 'osmode osm)
(setvar "cmdecho" 1)
(princ)
)

  ;;; Compute the cross product of 2 vectors a and b
(defun cross (a b / crs)
  (setq	crs (list
	      (- (* (nth 1 a) (nth 2 b))
		 (* (nth 1 b) (nth 2 a))
	      )
	      (- (* (nth 0 b) (nth 2 a))
		 (* (nth 0 a) (nth 2 b))
	      )
	      (- (* (nth 0 a) (nth 1 b))
		 (* (nth 0 b) (nth 1 a))
	      )
	    )				;end list
  )					;end setq c
)					;end cross
(defun unitV (v / d)
  (setq	d (distance '(0 0 0) v)
	d (mapcar '/ v (list d d d))
  )
)

 

 

 

 

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...