# align block to curve with 2 "base points" / car along curve

## Recommended Posts

Hi,

I've found the align object lisp from Lee Mac (thank you sir).

I have a slope for an underground garage where a special type of car can't pass the entrance (hanging too low).

They have given me a model of the car.

I want to align the car to the curve i've created.

The problem is that the car has two tires, represented by circles.

The point where they hit the curve is somewhere along those circles and i should align with 2 points to the curve.

Can you help me out?

The blue line is a section i've taken from the DTM,

The green line is a proposition i've made with trial and error.

Edited by B.N.

• Replies 27
• Created

• 5

• 5

• 4

• 4

#### Posted Images

Are you looking for something like this?

Block AUTO-1

MEASURE...

Regards

Jochen

##### Share on other sites

You want to do this to see if your curve will work? why not just use 3 point circle command and use tangent points of the two circles and the underside of the car. that will give you the absolute maximum radius you can use.

Edited by mhupp
##### Share on other sites

Your proposed profile does look a bit odd, going up and down. Surely the most efficient profile to get from one gradient to another is a circular curve.

I am not sure how a lisp programme would be of any use in this instance. Get the two gradients from the DTM and fillet between them with the radius given above (surely minimum radius, not maximum).

I see the ground clearance is 0.11 m. What happens if a driver of different weight gets in? Perhaps increase the ground profile radius to 10m.

##### Share on other sites

3 hours ago, scj said:

Are you looking for something like this?

Block AUTO-1

MEASURE...

Regards

Jochen

Something like that indeed! If I check your file there are some wheels below the curve. Why’s that? Thanks

3 hours ago, mhupp said:

You want to do this to see if your curve will work? why not just use 3 point circle command and use tangent points of the two circles and the underside of the car. that will give you the absolute maximum radius you can use.

Great! I can use this method! The client does want a view with repeated cars along the curve . Any solutions on how to automate that? Thanks!

13 minutes ago, eldon said:

Your proposed profile does look a bit odd, going up and down. Surely the most efficient profile to get from one gradient to another is a circular curve.

I am not sure how a lisp programme would be of any use in this instance. Get the two gradients from the DTM and fillet between them with the radius given above (surely minimum radius, not maximum).

I see the ground clearance is 0.11 m. What happens if a driver of different weight gets in? Perhaps increase the ground profile radius to 10m.

the odd design is because it is applied on an alignment view coming from a dtm.

There is a suggested margin of 4cm to cover the difference in load.

there is already a road placed so they want minimum demolition and a smooth curve up till the profile at the entrance (point where the section goes down)

##### Share on other sites

1 hour ago, B.N. said:

The client does want a view with repeated cars along the curve . Any solutions on how to automate that? Thanks!

No I do not sorry but i put it at the worst spot to bottom out. That's all they would really need. if it works there should work everywhere else. Tho I'm not a Civil Engineer.

--edit--

Crap sorry mate saw you where talking about the margin being 4mm have a list of drawing variable set when opening files to keep standards between my drawings one of those is to change the units to inches.

Edited by mhupp
##### Share on other sites

I would do it manually, but not tonight.

Lisp is no substitute for using AutoCAD properly.

##### Share on other sites

@B.N. You want something like this?

```(defun c:foo (/ a d e i p p2 xl)
;; RJP » 2021-04-27
;; Only works with plines drawn left to right
;; Block insertion 'auto' is bottom of back tire
(if (and (tblobjname "Block" "auto")
(or (setq d (getdist "\nEnter distance to place auto: <0.5> ")) (setq d 0.5))
(setq e (car (entsel "\nPick alignment: ")))
)
(progn (setq a 0)
(setq i 0)
(while (setq p (vlax-curve-getpointatdist e i))
(setq xl (entmakex	(list '(0 . "XLINE")
'(100 . "AcDbEntity")
'(8 . "TempXline")
'(100 . "AcDbXline")
(cons 10 (mapcar '+ p '(2.45 0 0)))
'(11 0. -1. 0.)
)
)
)
(if (setq p2 (vlax-invoke
(vlax-ename->vla-object e)
'intersectwith
(vlax-ename->vla-object xl)
acextendnone
)
)
(entmakex (list '(0 . "INSERT")
'(100 . "AcDbEntity")
'(410 . "Model")
'(8 . "Auto")
(cons 62
(if (< (setq a (1+ a)) 254)
a
(setq a 1)
)
)
'(100 . "AcDbBlockReference")
'(2 . "auto")
(cons 10 p)
'(41 . 0.01)
'(42 . 0.01)
'(43 . 0.01)
(cons 50 (angle p p2))
)
)
)
(setq i (+ d i))
(entdel xl)
)
)
)
(princ)
)```

Could be done like this too .. not sure which is more 'correct' for your use.

```(defun c:foo2 (/ a d e i p p2)
;; RJP » 2021-04-27
;; Only works with plines drawn left to right
;; Block insertion 'auto' is bottom of back tire
(if (and (tblobjname "Block" "auto")
(or (setq d (getdist "\nEnter distance to place auto: <0.5> ")) (setq d 0.5))
(setq e (car (entsel "\nPick alignment: ")))
)
(progn (setq a 0)
(setq i 0)
(while (setq p (vlax-curve-getpointatdist e i))
(if (setq p2 (vlax-curve-getclosestpointto e (mapcar '+ p '(2.45 0 0))))
(entmakex (list '(0 . "INSERT")
'(100 . "AcDbEntity")
'(410 . "Model")
'(8 . "Auto")
(cons 62
(if (< (setq a (1+ a)) 254)
a
(setq a 1)
)
)
'(100 . "AcDbBlockReference")
'(2 . "auto")
(cons 10 p)
'(41 . 0.01)
'(42 . 0.01)
'(43 . 0.01)
(cons 50 (angle p p2))
)
)
)
(setq i (+ d i))
)
)
)
(princ)
)```
Edited by ronjonp
##### Share on other sites

No need for trial and error.  Add points to the car (block) at the center of the tires and create an arc with a radius of the wheel base centered on the rear wheel (I assume the rear is to the left).

Construct an offset line to the surface profile at a distance equal to the radius of the tires (0.35 in your drawing).  Position the center of the rear (left?) tire on the offset line as shown here using osnap nearest.

Set osnap to endpoint, node, intersection and ow give the rotate command and click the center of the rear tire for the Base Point and then enter R and click the center of the rear wheel again and then the center of the front wheel and then click at the intersection of the red arc and the magenta offset line.

This will precisely position the car.

If you do not need precise rotation you can eyeball it!

Here's the result of 4 positionings.

##### Share on other sites

Thanks! solved my problem perfectly!!!

I've been helped to create the best curve and to place and align the car along that designed curve!

##### Share on other sites

I think your green line is unnecessary. If you take the DTM line (blue line) and position the car central to the change in gradient, there is 18mm of clearance. There is no need to do anything based on the information you have given.

Has the car grounded whilst being driven in, or is someone trying to forsee any possible awkward happenings?

##### Share on other sites

Probably something like this (picture borrowed from web)

##### Share on other sites

Here's one with animation... Just thought I'd do it for fun cause I'm a little bit bored around.

```(defun c:test (/ *error* acadobj activeundo adoc ang blk crv getcurve getinters gr grp grv i inp msp nm objs p1 p2 tmp vcl)
(defun *error* ( msg )
(foreach x (list vcl tmp blk)
(if x (vla-Delete x))
)
(if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*"))
(princ (strcat "Error: " msg))
)
)
)
(if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T))
(and
(setq getcurve
(lambda (msg / c)
(while
(progn
(setvar 'errno 0)
(setq c (entsel msg))
(cond
((= (getvar 'errno) 7) (princ "\nNothing selected"))
((not c) nil)
((not (wcmatch (cdr (assoc 0 (entget (car c)))) "LINE,LWPOLYLINE,ARC,CIRCLE,ELLIPSE,SPLINE"))
(princ "\nObject is not a curve")
)
)
)
)
c
)
getinters
(lambda (a / mx pt)
(while
(progn
(if (or (not mx) (> (car pt) (car mx)))
(setq mx pt)
)
a
)
(setq a (cdddr a))
)
mx
)
i 0
objs (ssget "_:L")	; Can be your car, or a selection of all other objects.
)
(setq p1 (getpoint "\nSelect first point for alignment <exit>: "))	; One of the wheels
(setq p2 (getpoint p1 "\nSelect second point for alignment <exit>: "))	; The other wheel
(setq crv (car (getcurve "\nSelect curve to align <exit>: ")))
(progn
(if (> (car p1) (car p2)) (mapcar 'set '(p2 p1) (list p1 p2)))
(while (tblsearch "block" (setq i (1+ i) nm (strcat "tmp" (itoa i)))))
(setq ang (angle p1 p2) blk (vla-Add (vla-get-Blocks adoc) (vlax-3d-point p1) nm))
(vlax-invoke adoc 'CopyObjects (JH:selset-to-list-vla objs) blk)
(setq crv (vlax-ename->vla-object crv)
vcl (vla-AddCircle msp (vlax-3d-point p1) (distance p1 p2))
tmp (vla-InsertBlock msp (vlax-3d-point p1) nm 1.0 1.0 1.0 0.0)
)
(vla-put-Visible vcl :vlax-false)
(while
(progn
(setq gr (grread t 15 0)
grv (car gr)
)
(cond
((member grv '(5 3))
(setq grp (vlax-curve-getClosestPointTo crv (trans grp 1 0)))
(vlax-put vcl 'Center (trans grp 1 0))
(setq inp (getinters (vlax-invoke crv 'IntersectWith vcl acExtendNone)))
(vlax-put tmp 'InsertionPoint (trans grp 1 0))
(vla-put-Rotation tmp (- (angle grp inp) ang))
(cond
((= grv 5))
((progn (vla-Explode tmp) t))
)
)
((or
(member gr '((2 13) (2 32)))
(= grv 25)
)
(*error* "exit")
)
(t)
)
)
)
)
)
(princ)
)

(defun JH:selset-to-list-vla (ss / rtn i)
(if ss
(repeat (setq i (sslength ss))
(setq rtn (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) rtn))
)
)
)```

##### Share on other sites

@B.N. Did you try any of the code provided ?

##### Share on other sites

5 minutes ago, ronjonp said:

@B.N. Did you try any of the code provided ?

I did!

I've tried all codes/solutions provided here.
Big thank you!

The first code you provided, is the one i've worked with in the end.

I've adapted the scale, bc sometimes my car became way too small

##### Share on other sites

30 minutes ago, B.N. said:

I did!

I've tried all codes/solutions provided here.
Big thank you!

The first code you provided, is the one i've worked with in the end.

I've adapted the scale, bc sometimes my car became way too small

Good to hear

##### Share on other sites

My \$0.05 did this many years ago and same thing uses 2 points. We found it was pretty simple to just zoom in and inspect very obvious were it hit.

As a side note Civil Site Design has this feature and can change vehicle template, can drag car back and forth.

For every one think the other plane ie horizontal just changed the block and spacing now had a forklift path checking for hit racking for a wide load.

Anyway some more theory as you can see this was a day to day check for us road reconstructions. Re the image above  if you do a double reverse curve using a radius of 13m the car will not hit. This is an arc ,the two contact points and the mid underside point. Using this can get a simple how far back does the garage need to be given rise from road.

Re scale as we would test on road cross sections normally plotted at 1:100 V  1:50 H so would block the sheet then change the y scale to 2, then rescale it all 0.1 so now its metric metres then explode so can get at plines.

Edited by BIGAL
##### Share on other sites

• 2 years later...

Good morning,

Many times I approached the modification of this wonderful program "foo" so that it was possible to insert a car with different wheels.

I managed to insert cars until there is only one point of intersection of the curve with the circle, when there are two points of intersection, the program stops.

I cannot program it to select the intersection point closer to the end of the curve Please help me with this problem.  My best regards

Short:  in  5 loops  code was break

```(defun c:foo3 (/ s a d e i p p2 xl)
;; WP>> 2023-09-07
;; RJP » 2021-04-27
;; Only works with plines drawn left to right
;; Block insertion 'auto' is bottom of back tire
(if (and (tblobjname "Block" "auto")
(or (setq d (getdist "\nEnter distance to place auto: <0.5> ")) (setq d 0.5))
(setq e (car (entsel "\nPick alignment: ")))
(setq s 2.4314)
)
(progn (setq a 0)
(setq i 0)
(while (setq p (vlax-curve-getpointatdist e i))
(setq xl (entmakex	(list '(0 . "CIRCLE")
'(100 . "AcDbEntity")
'(8 . "LayerName")

;(cons 10 (mapcar '+ p '(5 0 0)))
(cons 10 (mapcar '+ (list d 0 0) '(5 0 0)))
(cons 10 p)
(cons 40 s)
)
)
)
(if (setq p2 (vlax-invoke
(vlax-ename->vla-object e)
'intersectwith
(vlax-ename->vla-object xl)
acextendnone
)
)
(entmakex (list '(0 . "INSERT")
'(100 . "AcDbEntity")
'(410 . "Model")
'(8 . "Auto")
(cons 62
(if (< (setq a (1+ a)) 254)
a
(setq a 1)
)
)
'(100 . "AcDbBlockReference")
'(2 . "auto")
(cons 10 p)
'(41 . 0.01)
'(42 . 0.01)
'(43 . 0.01)
(cons 50 (angle p p2))
)
)
)
(setq i (+ d i))
(entdel xl)
)
)
)
(princ)
)```

##### Share on other sites

In my code same as other methods I used the quad point of the wheel circles not the wheel centreline. Did you check your wheel spacing v's the 2.4314 if that's metric wow a car wheel spacing  to 4/1000 of a mm.

Post a dwg make sure your block is in it, should be able to test.

Edited by BIGAL
##### Share on other sites

Thanx  a lot for the answer    Sorry for my English, I don't always understand the context of the statement. Bat this I undurstend

I didn't even think that the value 2.4314 is so precise, down to 4/1000 of a millimeter   "

This true I  use  metric  I  copied  Your's  block   "auto"  end not scal.

Sir  you  use  inthe code  Xline too  determined the intersection point n+1 using Xline, I don't know exactly how it works. I need to mark point n+1 with a circle or an arc (acrose withe curve), then I know that the intersections will be in the right place

In draw I   explanation in the drawing of what I meant .

I actually realized that I could solve my road light problem. After so many years I'm thinking  about this problem I'm  close, but unfortunately it's too difficult for me to use loops.

Pleas  for the light in tunnel

Regard Woldo

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

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.