Resource icon

Misc Blender addon: Import/Export .ai/.csv/.ini files 2.2.0

Login or Register an account to download this content
Judging by the behavior I see when editing border line of 2-way traffic AI lines, where the border line often cuts into itself, AC doesn't care about where to put vertex 0 because it does not build a one-to-one relationship between border line vertices and fast lane vertices. It's simply using the csv to build a mesh of border wall and ray cast towards that wall to calculate border distance. Where vertex 0 is has no impact on the shape of the wall mesh, hence no difference in the border distance result computed.
 
Last edited:
I've managed to create a valid AI line file without recording.

In the 18 floats per vertex section, f[0] of the very first vertex is the single-precision float epsilon value multiplied by number of points (1.40129846432481E-45 * numberOfPoints) . f[6] and f[7] are border distance values. Everything else can be left as zero. The unknown data block after this section can also be ignored. Once such a file is created, load it into ksEditor (will take a long time), resample if necessary, and save the file. ksEditor will generate some of the missing data, and the data channels that can not be regenerated correctly don't seem to have any impact on AI behavior.

Run the attached script against a csv to create a AI line file in this way: acai_csv_to_line.py input.csv output.ai .
 

Attachments

  • acai_csv_to_line.py.txt
    1.7 KB · Views: 136
Last edited:
Bug report / feature suggestion :

In your export_csv.py, you used range(len(bm.vertices)-1) to loop through the vertices during output, so the last vertex is always ignored. But why? Looking at your comment, avoiding a normalized position value of 1.0 seems to be the reason, but is this really a problem? How about increasing distTotal slightly so position never reaches 1.0, or simply clamping it to 0.99999? With your current solution every time a line is exported one unlucky end point gets lost, which is really annoying when precision is needed.

Another issue is how the add-on connects the first and the last vertices when importing a csv or AI line. For circuit tracks this makes sens. But for A2B the extra line shouldn't be there. Whether a track/line is circuit or A2B can be tested with reasonable confidence by calculating the distance between first and last vertex and the angle between first and last segment. If the dot product of first and last segment vectors is positive and the distance between two end points is smaller than a threshold, connect the two end points. Otherwise render the line as A2B.
 
Last edited:
Bug report / feature suggestion :

In your export_csv.py, you used range(len(bm.vertices)-1) to loop through the vertices during output, so the last vertex is always ignored. But why? Looking at your comment, avoiding a normalized position value of 1.0 seems to be the reason, but is this really a problem? How about increasing distTotal slightly so position never reaches 1.0, or simply clamping it to 0.99999? With your current solution every time a line is exported one unlucky end point gets lost, which is really annoying when precision is needed.

A related issue is how the add-on connects the first and the last vertices when importing a csv or AI line. For circuit tracks this makes sens. But for A2B the extra line shouldn't be there. Whether a track/line is circuit or A2B can be tested with reasonable confidence by calculating the distance between first and last vertex and the angle between first and last segment. If the dot product of first and last segment vectors is positive and the distance between two end points is smaller than a threshold, connect the two end points. Otherwise render the line as A2B.
Go fork it if you find it anoying!

Well thx for feedback, I was happy enough to get it working finally. I didnt care really for one last point, but is this really a problem :) ?

I might fix this, but not this:

The connecting edge from first to last - why you make such a big issue of it, if it bothers you - just remove it in Blender and you can be happy. Its just like AC does it too and spared me the anoyance of using dot products :)
 
Last edited:
Bug report / feature suggestion :

In your export_csv.py, you used range(len(bm.vertices)-1) to loop through the vertices during output, so the last vertex is always ignored. But why? Looking at your comment, avoiding a normalized position value of 1.0 seems to be the reason, but is this really a problem? How about increasing distTotal slightly so position never reaches 1.0, or simply clamping it to 0.99999? With your current solution every time a line is exported one unlucky end point gets lost, which is really annoying when precision is needed.

Another issue is how the add-on connects the first and the last vertices when importing a csv or AI line. For circuit tracks this makes sens. But for A2B the extra line shouldn't be there. Whether a track/line is circuit or A2B can be tested with reasonable confidence by calculating the distance between first and last vertex and the angle between first and last segment. If the dot product of first and last segment vectors is positive and the distance between two end points is smaller than a threshold, connect the two end points. Otherwise render the line as A2B.
ok the last-point-thing is just an oversight of me, after doing
1630322207413.png

its not needed to loop one vertex less, so i just can remove the "-1" from the loop. Thx! Will post an update soon.
 
Please Stop This updated Blender addon: Import/Export .csv and .ai files with a new update entry:

v1.6 - 5th dec 2021

-fixed stupid version check preventing it to work on Blender 3.0
-added option for exporting to CSV to skip PoT value
-added importing/exporting from/to camera.ini files (plain axis empties, camera.inis must exist for export)

Read the rest of this update entry...
 
Is it possible to export fast_lane.ai to an .ai file without checking the vertex count?
This is useful for AI server which only needs fast_lane and it can be made in blender itself based on roads from 3D model.

Python: RuntimeError: class EXPORT_AI_OT_write, function execute: incompatible return value , : 'AI-line point count and vertex-count of selected mesh dont match!' not found in ('RUNNING_MODAL', 'CANCELLED', 'FINISHED', 'PASS_THROUGH', 'INTERFACE')

location: <unknown location>:-1
 
Hi there,

I'm trying to install in Blender 3.1, it installs but don't let it become enabled.

I notice that appears a warning icon and a message related saying that Blender 2.8 or above is required.

Nevertheless when I try to enable it I receive the error message.

Can somebody help? Can't make it work.
 

Attachments

  • Captura de tela 2022-06-06 233840.png
    Captura de tela 2022-06-06 233840.png
    643.7 KB · Views: 32
Last edited:
Hi there,

I'm trying to install in Blender 3.1, it installs but don't let it become enabled.

I notice that appears a warning icon and a message related saying that Blender 2.8 or above is required.

Nevertheless when I try to enable it I receive the error message.

Can somebody help? Can't make it work.
Uff, see that too now, i dont know why, it was working before ...

Blender 3.1 installs addons into your user folder
('C:\\Users\\klausi\\AppData\\Roaming\\Blender Foundation\\Blender\\3.1\\scripts\\addons),
but it wants to load it from its script folder... !? No idea whats goin on there...
1654600804811.png


So just unpack manually to:
C:\Blender31\3.1\scripts\addons\

Then in blender just enable it:
1654600955930.png
 

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top