Notifications
Clear all

[Closed] Automatic Line Drawing Tool

I am looking for a little help on making a script to automate the keyboard input creation method of creating a line drawing. For instance if you mess up with the keyboard input you pretty much have to start over. My ultimate goal is to have the script take inputs from a ui that will let me specify point a = 1.2 m on a 2% slope point b = 2 m on a 16% slope and so on. I am making shapes to use with the loft of roadway sections and it is very tedious to do it point by point using the keyboard input especially if I calculate one wrong point then I have to start over. Is there a command to be able to draw a line and put vertices at the correct location with the correct slope by using a ui? I have been trying to do this and cant find a way to create a line by vertex input. I even tried the listener to see what it does on the keyboard input and it doesn’t show anything while you are using keyboard input just the initial point is displayed. If I could figure out how to create a line with mulitple points then I could do the math for the rest so I guess my biggest question is how to create a line string by inputs using a script.
Thanks for the help

3 Replies

It’s quite a simple process, you need to calculate your points (via slopes and distances) yourself, but making a spline is easy.

Here is some sample code that will create a spline shape and add 100 randomly placed vertices to it.

(
	local shp = splineShape() -- Create a new spline shape object
	
	addNewSpline shp -- add a new spline to the shape
	
	for i = 1 to 100 do
	(
		-- add a smooth knot (or vertex) to the spline as part of a curve at a random spot.
		addKnot shp 1 #smooth #curve (random [-1000, -1000, -1000] [1000, 1000, 1000])
	)

	updateShape shp -- Update the spline shape to ensure that it's displayig properly
)

I hope this helps you understand spline creation

Great, Thanks! I know how to make a ui and how to create primitives and such I just never have done line strings

Here is what I have so far. I am running into a block though. Instead of automatically or randomly creating vertices I want to input them seperatley by distance and slope then move on to the next point by hitting the next button and imput the coordinates for the next point when I am done inputing I want to hit create shape and have it close the shape. The script as I have it now just joins two points by inputing a distance and slope then hitting create shape. Can anyone help me be able to input one distance/slope then hit the next button and input another distance/slope and keep going till I hit create shape then have it close the object. Thanks

Here is the script so far, I will also attach a copy of it.

[size=1]Try (Destroydialog Typ_Sec) catch()

rollout Typ_Sec “Typical Section Creator”

(

Group “Inputs”

(

Spinner spn_distance “Distance ” align:#left

Spinner spn_slope “Slope ” align:#left offset:[0,0]

)

Button but_next “Next ” align:#left

Button but_shape “Create shape” align:#center offset:[0,-26]

on but_shape pressed do

(

fn drawLine pointA pointB =

(

shp = SplineShape pos:pointA

addNewSpline shp

addKnot shp 1 #corner #line PointA

addKnot shp 1 #corner #line PointB

updateShape shp

shp

)

DD = spn_distance.value

DS = spn_slope.value

newSpline = drawLine[0.0,0.0,0.0] [dd,(ds*dd),0.0]

))

createDialog Typ_Sec 200 100

[/size]