Jump to content

Fence / Power Placement Script


WrinkleysRule

Recommended Posts

  • Wrinkley

This script can be used to easily place fences/power lines on a map using a spline.

It consists of a basic spline placement script and a modified easyFence script (by modelleicher) combined with some extra enhancements.

The script works by first placing posts/poles aligned to the terrain along a spline, it then places fence boards/wires on these posts/poles scaling them to match the distance to the next post/pole.

 

To install download the script (available at the end of this tutorial) unzip the fencePowerPlacement.zip and Copy/Paste the script into

C:\Users\Your Computer Name\AppData\Local\GIANTS Editor 64bit 9.0.4\scripts.

Once installed, to initiate the script select the Fence Power Placement script in the GE Scripts tab.

A panel will pop up somewhere on the screen.

The image below shows the Panel, together with a brief description of the Inputs/Parameters

tmObC3b.png

 

 

Points to Note before using this script.

All posts/poles/wires/boards Must be scaled at 0,0,0 before use in the script

Items to be placed Must be aligned along their ‘Z’ axis with the point of origin at one end.

Number of Wire/Board alignment nodes Must be the same on all posts/poles used and in the same order top to bottom otherwise you will have crossovers between the posts.

hG6kDaC.png

 

 

The post/pole transform group hierarchy must always start with the post mesh followed by the wire/board alignment nodes it can then be followed by any other meshes although I think best practice would be to have a single mesh for the pole/post including all the parts.

The following image shows the transform group hierarchy and the telegraphPost  placed using the script

m0pL5yB.png

 

Above Telegraph pole taken from the FS19_telegraph pole kit by Robbie available on modhub

Placing  a Simple Fence

 

Simple post, fence board creation

For this example I will create a simple post/board using the Create- Primitive - Cube in GE

The finished fence will consist of square posts and three fence boards

If  you already have a suitably aligned post and  fence board then skip the next section, import post and fence wire/board into GE and go to Adding the alignment nodes to a post. section.

If not continue with the following,

 

In GE Create - Primitive - cube

In the attributes panel Translate 'Y' enter 0.5 also rename this post_1

Select Edit - Freeze Transformations and select Translate - this will move the cubes point of origin to the base of the cube

In the attributes panel enter the following into the Scale transforms 'X' 0.15 , ‘Y’ 1.5, 'Z' 0.15 and Freeze transformation Scale (only Scale ensure all others boxes are deselected)

In the material panel in Albedo Colour enter 0.4, 0.2, 0.2 this will give a brownish colour to the post

Create a second cube

In the attributes panel Translate 'Z' enter 0.5 and rename this to board_1.

Select Edit - Freeze Transformations and select Translate - this will move the cubes point of origin to edge of the cube

In the attributes panel enter the following into the Scale transforms Scale 'X' 0.1,  'Y 0.2  'Z' 4 and Freeze Transformation Scale (only Scale ensure all others boxes are deselected)

Because this second cube still uses the material name ‘Unnamed material’ it will be the same colour as the post.

Create a new transform group and name this fencePowerItems

Select post_1 with the middle mouse button and keeping the middle mouse button pressed move post_1 into the fencePowerItems transform group, do the same with board_1.

The reason for this is to keep the transforms all set to 0,0,0, which will prevent any unseen conflicts with translation positions.

With the fencePowerItems transform selected on the keyboard select Ctrl B to place it in your current view port for reference.

 

Adding the alignment nodes to a post.

 

Create a new transform group –Create – Transform Group

Select the new transform group with the middle mouse button and keeping the middle mouse button pressed move the new transform group into the post_1 transform.

If you do not have a middle mouse button then cut/paste the new transform into the post transform.

Next move the new transform up to where you want the lowest board to be

With the new transform selected on the keyboard select Ctrl D to duplicate then move this second transform to the centre board position, repeat this step for the third transform placing it where the top board will be.

Your post_1 alignment transforms should look like the post in the alignment image above.

Your post transform should look like the following image

ntnSxkD.png

 

Open your map in GE

Create a spline – Create- Spline rename to spline_1 and align it along the route you want to place your fence.

Select  Scripts – Fence Power placement to initiate the script.

In the Scenegraph a new transform group ‘fence_powerObjects’ will have been created consisting of three transform groups

wire_fenceNode – place the fence board(s), wire(s) in this transform group

fencePlacement Transform Group

postObject – place your post(s)/ pole(s) in this group

placedObjects – your complete fence/power line will be placed in this group when the script has been executed (select Create Fence/Power Line)

The spline has to be placed in the fencePlacement Transform Group

For those familiar with the original Spline Placement script this fencePlacement Transform Group works in the same way as the Spline Placement script.

 

I have renamed the post_1 and board_1 meshes to post1S1,board_1S1 (S1 being spline_1) respectively.

Unfortunately GE will scale all objects of the same name throughout the map so I have done this so that I can easily freeze the scale transformations on the completed fence/power line without affecting any other mesh in the map.

Copy/Paste  board_1 into the wire_fenceNode transform (rename if you want to).

Copy/Paste  post_1 into the postObject transform. (rename if you want to).

Cut/Paste the spline into the fencePlacement transform

Set Post Distance – 4 – posts will be set 4m apart

Stay Upright – Selected – this will ensure the posts remain upright regardless of terrain contour

Select Random Spline Order – Deselected – this will be used in a later section of the tutorial

Select Random Wire/Board Placement – Deselected -- this will be used in a later section of the tutorial

No of Wire/Board Nodes – 3 – this is the number of transform nodes on the post

Maximum Posts – 0 – Default setting means all post will be used

Start Post – 0 – default setting script will start at first post

Remove Current Fence/Power Placement – Deselected

With the fencePlacement transform Selected,  

Select the Create Fence/ Power Line button

The fencePlacement transform must be selected for the script to run.

In following image ‘Image 1’ shows the renamed post_1 and board_1 in their correct transform groups together with the spline in its correct position and the Fence/Power Placement Panel ready for input.

 

Image 2 shows the Fence/Power Placement Panel with all the relevant data entered and the script executed by selecting Create Fence/ Power Line button

Image 3 shows another view of the placed fence and the two other insets shoe the difference between Selecting/Deselecting the Stay Upright parameter

 

cWTVhpf.png

 

You can check out the difference between the Stay Upright modes by,

 Remove Current Fence/Power Placement –Select – this will delete the current fence placement

Stay Upright – Deselected

Remove Current Fence/Power Placement –DeselectImportant step otherwise new placement will not take place

Select -- Create Fence/ Power Line button – this will create the same fence placement but with the posts following the terrain contour

To return to the original placement,

Remove Current Fence/Power Placement –Select

Stay Upright – Selected

Remove Current Fence/Power Placement –DeselectImportant step otherwise new placement will not take place

Select -- Create Fence/ Power Line button

The Remove Current Fence/Power Placement selection can be used to delete an existing placement and  add/change any parameter then execute the script with the new settings.

 

For wire placement the alignment method is slightly different in that the transform nodes are placed on the outside of the post on the ‘X’ face.

Sbi1lVy.png

 

Although normally a fence post created for wire would already have the staples (the staples would have to be on the ‘X’ face of the post) as an integral part of the post mesh.

 

Random Post/Board Placement

For this example I have created a shiny round post by,

Create – Primitive – Cylinder

Rename – post_2

Translate ‘Y’ – 0.5  Freeze Transform Translate

Scale X 0.2, Y 2, Z 0.2 Freeze Transform Scale

Albedo Color 0.8,0.8,0.8,  Smoothness 1 Metalness 1

Cut Paste into fencePowerItems Transform

For the boards I have just duplicated board_1 twice renamed board _2, board _3 respectively and scaled X,Y values (not Z as this is the distance between posts) then Freeze Transformed scale on the new boards

Ctrl B the new fencePower Items to your map location

The alignment nodes on the post are set up the same way as  for the post_1 (must be the same number)

Copy/Paste  board_2,3 into wire_fenceNodes

Copy/Paste  post_2 – into the postObject transform

Using the same spline the script set up is as follows

Set Post Distance – 4 – posts will be set 4m apart

Stay Upright – Selected

Select Random Spline Order –Selected

Select Random Wire/Board Placement – Selected

No of Wire/Board Nodes – 3 – this is the number of transform nodes on the post

Maximum Posts – 0 – Default setting means all post will be used

Start Post – 0 – default setting script will start at first post

Remove Current Fence/Power Placement – Deselected

With the fencePlacement transform Selected, Select the Create Fence/ Power Line button

The image below shows the Script parameters and random placement of both the posts and boards

XpMuzQy.png

 

If you want to create some missing fence boards add another empty transform group to the wire_FenceNode transform group.

 

The odd posts are deliberate to highlight the effect of the random spline placement

 

Power Lines

I will be using some premade power pole and  wires for this example

 

An example of a power pole with multiple objects is shown in the Points to Note before using this script  section at the beginning of this tutorial

The alignment node set up method is slightly different for the power poles.

Create a transform group and Select the new transform group with the middle mouse button and keeping the middle mouse button pressed move the new transform group into the powerPole transform group.

With the new transform node selected, hover the mouse over the insulator you want to hold one of the wires, then Ctrl B left click twice to place it on the insulator

Do the same for all the other insulators

3v1SFpj.png

Image below shows the placement of Power Lines together with the relevant script settings, inset gives a clearer picture of the placement

JUyOxLb.png

 

Below Power Placement using the Select Random Wire/Board Placement with an extra saggy wire (wireSag2) randomly placed again inset shows clearer placement

hakz9d0.png

 

Finally using the script twice to place power Lines and a damaged barbed wire fence

quUiGvM.png

 

Further Notes

Wire_FenceNode objects must be single meshes and not part of any transform group.

There is no limit on the no of items that can be placed in either the wire_FenceNode or the postObject node the only stipulation on extra posts is that they must all have the same number of alignment nodes.

Post/poles must also be single meshes and not part of any transform group.

The alignment nodes on any post/pole must be the first children of that mesh, however other meshes can be placed after the alignment nodes for example

s2nktZi.png

 

Though currently if using a tree it will only be placed in one rotation and LOD1 is not supported.

You can of course manually place a tree in place of a post by first selecting the post in the viewport and then in the scenegraph copy the three transform nodes of that post.

Using the replace function select the post as the Target and the tree in the Replace With section and select Replace, align the tree with the end of the previous posts wires and with the tree transform group selected paste the original 3 transform  copied previously into it

The following image shows the result  of this method

4r2fkPx.png

 

Error Messages

 Error messages will appear in the console log if,

Nothing is in the wire_FenceNode transform group

Nothing is in the postObjects transform group

Incorrect number of transform alignment nodes on a postObject item error message and name object will be printed in the log

Spline is in the wrong transform group or not present in the fencePlacement transform Group

When the script has finished the following will be printed in the log

Finished! Enjoy the fence 🙂

Spline Name: (name of spline)

As normal I suggest you try this script out on a test map before using on any WIP map also this script is still being developed so may change at a later date.

Original Easy Fence script available here select all and paste into new notepad++ file and save as easyFence.lua.

https://pastebin.com/1DR6qDcE

Damaged barbed wire/poles taken from FS 19 Barbed wire fence kit by Robbie

https://www.farming-simulator.com/mod.php?mod_id=105801

 

 

 

 

 

 

 

Fence_Power_Placement.zip

  • Thanks 3
Link to comment
Share on other sites

  • Wrinkley

Heres a little extra when placing power lines, after placing select the Spline Paint Panel script  and in the settings,
Set Centre Width  -- 2
Set Edge Width    -- 0.5
Set Edge Texture Left -- Select --Rough Grass
Set Centre Texture -- Select -- Gravel
Set Edge Texture Right -- Select --Rough Grass
Set Texture Distance -- to the distance between your post
Select Paint button
Grass gravel will be placed at the base of each of your poles, due to the way the terrain segments are painted in GE some may be placed slightly to one side of the pole

Note: If the distance between your poles is more than 50m then you will need to adjusy the texsDistance value at line 127 in the script from 50 to a suitable larger setting eg 150 (150m)

Spline Paint Panel script available at the end of this tutorial

https://farmerboysmodding.com/index.php?/topic/2439-new-spline-paint-height-csv-field-creationdimension-panel-scripts

You can also use the Paint Foliage by spline script in the same way

The Fence_Power_Placement script has also been updated (08/10/2023)

Edited by WrinkleysRule
Script Update
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now