• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How to make railway stations by script ?

Explorer ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

Hello,

I have question: simply how having what is on pic. A to make what is on pic. B by script ?

I guess it is not so easy so I can pay for making this.

 

----

More explanation: I have railways as lines and railway stations as dots. I can easy make stations with a proper symbol (white rectangle), but it should to be aligned along the railway. And I have many stations like these.

 

Thank you,

 

A.pngB.png

TOPICS
Draw and design , Scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

Which version of Illustrator are you using?

 

Also, can you share a sample .ai file, so one may have a look at it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

The crux is getting the tangent of the curve where there's a rectangle and therefore the angle of rotation of the rectangle, so that the two are "aligned".  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

Beff,

 

As Femke said, the right rotation is crucial.

 

In addition to that, I believe the right visual appearance is also crucial, and I believe that includes your positioning the rectangle so that both midpoints of the end segments of the station rectangle are exactly over the line path.

 

I would suggest a two step procedure based on a rectangle (symbol) that has an actual Anchor Point at each of the end segment midpoints, Smart Guides being your friends:

 

1) Once the dot has been replaced by the rectangle (symbol), with the Rotate Tool simply rotate the rectangle by one of the midpoints to snap to the line path; if the line path is straight (or has an unusual line shape with an inflexion at the station centre and identical curvatures on either side) you are done already;

2) Select the point from 1) as the rotation centre and rotate the rectangle by the other midpoint to snap it to the line path.

 

This would give you the (fake) appearance of the rectangle being centred on the line path, by the centring of its end midpoints, which obviously means that in most cases the station centre will (normally) be moved a wee bit sideways from the line path (and often (much less) along the line path).

 

I (also) believe that Kurt has something like/unlike that in mind already and wishes to give you the best/easiest way depending on version and what you have in your document alreadey.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

This is completely off topic, but I tried this recently and thought you might be interested (stacking strokes to make railway tracks). https://www.youtube.com/watch?v=Pd5kdkSChFg

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

You might be able to replace the dots with type on a path. Wingdings "n" will give you a solid box. Color it white and add a black stroke, scale the box width as needed. Separate the stations with a tab.

Type on a path.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

Thank you, Luke, for your answer. I am looking at this and the videos with interest.

 

You may be surprised, but I was breaking my head to solve the same problems, which they have in the videos.

 

Right, I may change dots with "n". But what, when the dot is not on the line, but aside ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

I think it is still necessary to share a sample .ai file in order to provide possible solutions. At least if pure assumptions are not desired.

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

Hello,

OK, I am uploading an .ai

I am using AI 2020

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2020 Sep 19, 2020

Copy link to clipboard

Copied

Beff,

 

While we wait for an exquisite (version of (something with the same resulting appearance as) the suggested two step way) solution, you can compare that way to a simple/single centred rotation at a position on a normal maximally curved stretch away from an inflexion as in your screenshot B part (which is a bit overly rotated); and see how the latter will have the rectangle ends stick out of the line path, off the curve.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 19, 2020 Sep 19, 2020

Copy link to clipboard

Copied

This is a dirty mock-up which does it.  (Dirty because it uses Divide Objects Below through executeMenuCommand to get the tangent of the curve, which—as said—is the crux of the problem.)  Be warned, there are many variables which will cause failure.  But the point is, it can be done.

 

Untitled2020.png

 

// select dot
var items = app.activeDocument.pathItems;
var railway = items["railway"];
railway.locked = true;
app.executeMenuCommand("Find Appearance menu item");
var rects = [];
for (var i = selection.length - 1; i > -1; i--) {
  var x = selection[i].position[0] + (selection[i].width/2);
  var y = selection[i].position[1] - (selection[i].height/2);
  selection[i].remove();
  rects[i] = items.rectangle(y + 12.5, x - 5, 10, 25);
  rects[i].name = "station" + i;
  rects[i].strokeColor = app.activeDocument.swatches["Black"].color;
  rects[i].fillColor = app.activeDocument.swatches["White"].color;
  rects[i].locked = true;
}
for (var i = 0; i < rects.length; i++) {
  rects[i].locked = false;
  var params = [rects[i].top, rects[i].left, rects[i].width, rects[i].height];
  var tempRailway = railway.duplicate();
  tempRailway.name = "tempRailway";
  tempRailway.move(rects[i], ElementPlacement.PLACEBEFORE);
  tempRailway.locked = false;
  tempRailway.selected = true;
  app.executeMenuCommand("Knife Tool2");
  app.activeDocument.selection = null;
  if (items[1].top > items[0].top) {
    items[1].moveBefore(items[0]);
  }
  items[0].translate(0, -1);
  items[0].selected = true;
  app.executeMenuCommand("Knife Tool2");
  items[0 + 1].remove();
  var T = items[0].height / items[0].width;
  var x1 = items[0].pathPoints[0].anchor[0];
  var y1 = items[0].pathPoints[0].anchor[1];
  var x2 = items[0].pathPoints[2].anchor[0];
  var y2 = items[0].pathPoints[2].anchor[1];
  if ((x1 < x2) && (y1 > y2)) {
    var degree = 90 - (Math.atan(T) * (180 / Math.PI));
  } else if ((x1 < x2) && (y1 < y2)) {
    var degree = -90 + (Math.atan(T) * (180 / Math.PI));
  } 
  items[0].remove();
  rects[i] = app.activeDocument.pathItems.rectangle(params[0], params[1], params[2], params[3]);
  rects[i].rotate(degree);
  rects[i].move(railway, ElementPlacement.PLACEAFTER);
  rects[i].locked = true;
}
railway.move(rects[0], ElementPlacement.PLACEAFTER);

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

Almost perfect, femkeblanco 🙂

Sometimes the angle is OK, and sometimes not.

Map00.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2020 Sep 19, 2020

Copy link to clipboard

Copied

Type on a path, above stacked stroke graphic style.

RR tracks.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2020 Sep 19, 2020

Copy link to clipboard

Copied

That's a very good concept, femkeblanco.

 

I have a similar idea, but it is based on actions and graphic styles. Optionally, it may offer a way to create bended stations (which sometimes look a bit nicer depending on the curves).

 

I'm looking forward to Beff's sample .ai file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2020 Sep 19, 2020

Copy link to clipboard

Copied

Beff,

 

Here are comparative views of appearances based upon the Tangent way and the suggested Two step way, for a gently curved stretch as in your screenshot and for a more strongly curved one.

 

The stations in the middle, including the original one, are at the inflexion.

 

 

Like Kurt, I also considered station shapes following the line shape but abandoned it, possibly wrongly assuming your preferring rectangles as specified in your explanation as opposed to a variety os shapes from straight to (more or less strongly) curved and including inflexion.

 

It would also be conceivable to prefer an intermediate positioning building on both ways, which would be more complicated than the sum of both single ways.

 

 

I have kept forgetting one aspect, namely that the Tangent way requires an actual Anchor Point on the line path at each station (irreversibly changing the stretch(es) in question) whereas the Two step way can be used on the line path as it is.

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 19, 2020 Sep 19, 2020

Copy link to clipboard

Copied

Bonjour,

Jacob, je n'ai pas tout compris ce que tu veux dire (problème de traduction)

Cependant je viens d'éditer un script rapide qui fait le travail suivant:

Je n'ai pas sélectionné les points extrémitées du tracé afin de montrer le sens du tracé.

Le résultat es identique si j'inverse le sens du tracé.

L'élement placé est un symbole (station mise à l'échelle 60), il peut avoir une toute autre forme..

Capture.PNG

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2020 Sep 19, 2020

Copy link to clipboard

Copied

Hi.

Take a look at FindReplace from Astute Graphics.

This plugin lets you Locate or Select by color, size, shape, text type, image resolution, group attributes, etc. Also, you can Replace located items with any sampled artwork. Position, scale, and rotate based on the original object(s). Options to pick replacement artwork from a group randomly or consecutively, and position based on points and handles along path(s).

For more info please check the following YouTube Playlist:
https://www.youtube.com/playlist?list=PLVuiTl_w4-zAEg7ayKvExeIfTakWD87D7

Best Regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2020 Sep 20, 2020

Copy link to clipboard

Copied

René,

 

Jacob is saying that in "real-world" railway maps it looks more accurate and pleasing to the eye if the rails cross the stylised railway buildings exactly at the centre of their two small sides. I second that approach.

 

That means that the computation base for an automated (scripted) way would rather be the tilt angles of chords, and not tangents. Of course this may be pretty difficult as there can be many unknown variables (for example different dimensions of the desired stations).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2020 Sep 20, 2020

Copy link to clipboard

Copied

Ough, I see I have uploaded nothing. So I repeat.

I see I gave you a nice task 🙂

 

And yes, it can be a part of curve. Usually the railway curves are very smooth, never sharp.

So, theoretically it can be a fragment of path, not to complicate too much.

https://we.tl/t-FBd3zfm6i1

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Kurt,

Merci pour les précisions.

J'ai téléchargé l'exemple de Beft, à l'ouverture sur CS6, je constate que le chemin est composé de segments de droite.

C'est la même chose sur une version plus récente ?

René

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Here you can take a look how it looks in practice: https://opentopomap.org/#map=14/47.20289/10.68609

Move a little left / right, you will find more stations.

 

Please note that as for me I needn't stations to be in different sizes. All in the same size is OK.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Beff,

 

I can see from the map that many of the curves are much sharper than the ones I drew (radius 14 x the station length), about twice as sharp at the very station in Roppen, and I believe that a stretch like the one to the west of Landeck may hit a station somewhere with a much sharper curve.

 

And unless the stations get their own colour I am afraid they would become even more difficult to spot without the rigid rectangle shape.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

The station may be on curve. Nothing bad in that. But I see when it is not a curve, but straight fragments, may cause a problem. Damn it.

 

I expected it would be tough, but it is more tough than I expected.

 

That's why I wrote I could pay for it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Thanks for the sample file, Beff.

 

I'm not quite sure if we are now perhaps talking about a completely different situation. As René already mentioned, none of your (fragmented) railway paths are smooth curves. They all consist of straight segments.

 

Moreover, the four stylised stations (dot symbol instances) are located beside the rails and not centred on top of them.

 

Don't you have a nicer file that may be a bit more in tune with your initial request? In my view, your current sample file is pretty bleak.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

If this is what you are working with, you can simplify the curves to some extent (Path> Simpify) but you might introduce some errors to the exact location of the tracks. The size of the artboard is 500 cm, is this what you want?

Simplify path.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines