Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FCStd read and write nodes #3674

Merged
merged 52 commits into from Apr 12, 2022
Merged

add FCStd read and write nodes #3674

merged 52 commits into from Apr 12, 2022

Conversation

rastart
Copy link
Collaborator

@rastart rastart commented Oct 26, 2020

new nodes (exchange)

FCStd read - import parts from single or multiple freecad project files
filter by name feature

FCStd read Sketches - import Sketches from single or multiple freecad project files
filter by Sketches name

FCStd write - write solid or mesh parts in a single freecad project file

FCStd Spreadsheet - read/write parameter from a freecad spreadsheet

Approximate Subd to Nurbs - convert an obj (with subd modifier) to NURBS

FCStd read features

filter by name -dropdown enum list
select the part to be imported

read_update -bool
enable/disable reading

read_body -bool
enable/disable reading freecad Body

read_body -bool
enable/disable reading freecad Parts

tool_parts -bool
enable/disable reading freecad parts/features inside a solid operation or body ( it read just the final output)

invert filter -bool
invert filter selection

input-> file path -path
input-> part list -string (OPTIONAL: part labes in string list format)
output-> -solid

FCStd Sketch read features

mode -dropdown enum list
read mode: only geometry , only construction geometry, both

filter by name -dropdown enum list
select the sketch to be imported

max_points -int
parameter to resample the geometry by set max points in relation the the max geometry curve length

invert filter -bool
invert filter selection

read_update -bool
enable/disable reading

input-> file path -path
input-> part list -string (OPTIONAL: part labes in string list format)
output-> -verts
output-> -edges
outputs-> -curve

FCStd write features

write_name -string
name of the part(s) to be written
a suffix _SV_ and a numeration will be added to the name
to avoid delete erroneusly parts in the freecad project.
The writed parts will be overwrited on node update.

format -enum
select mesh or solid format

write_update -bool
enable/disable writing

input-> file path -path

solid mode:
input-> -solid
mesh mode:
input-> -verts
input-> -faces

FCStd Spreadsheet

filter Spreadsheets by name -dropdown enum list
select the freecad Spreadsheet

filter Spreadsheets cell by alias -dropdown enum list
select the freecad cell alias in the selected Spreadsheet

write parameter
set the node to write mode

input-> file path -path
input-> cell in -float
output-> cell out -float

important

Code tested both in blender 2.93 (py3.9) and freecad 0.2 (py3.9)
More tests required to ensure safe usability.

  • FCStd read node: needs label list input to filter parts
  • FCStd Sketch read node: need testing, complete curve translation and a better label...
  • FCStd read node: write dropdown freecadpart list node
  • FCStd spreadsheet node: read / write mode
  • code refactoring
  • fix for blender 2.93 / freecad 0.20 py3.9
  • add an update button
  • Approximate Subd to Nurbs node added
  • Approximate Subd to Nurbs node sorting algorithm improving
  • Approximate Subd to Nurbs node debugging
  • nodes review / testing
  • add docs
  • ready to merge

update_buttons

@vicdoval
Copy link
Collaborator

Some docs would be nice before merging... :)

@rastart
Copy link
Collaborator Author

rastart commented Oct 27, 2020

ok, are there some example I can follow?

here some screen about use cases:

read node without filter keys, import all freecad parts visible/hidden

read_all

read node with filter keys

read_filter

read node with filter keys

for part design is important to filter the final step of the body tree

read_pt_design

write node - solid mode

write_solid

write node - mesh mode

write_mesh

nodes/exchange/FCStd_read.py Outdated Show resolved Hide resolved
nodes/exchange/FCStd_read.py Outdated Show resolved Hide resolved
nodes/exchange/FCStd_read.py Outdated Show resolved Hide resolved
nodes/exchange/FCStd_write.py Outdated Show resolved Hide resolved
rastart and others added 5 commits October 27, 2020 15:58
Co-authored-by: Durman <sv@soluyanov.ru>
Co-authored-by: Durman <sv@soluyanov.ru>
Co-authored-by: Durman <sv@soluyanov.ru>

else:
self.inputs.new('SvSolidSocket', 'Solid')

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this function is called obj_format will always be the default value (solid)

Copy link
Collaborator Author

@rastart rastart Oct 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I noticed a strange behaviour with the enum, also if I save sometime when I reopen the file the value is changed.
I'll look better at how this is implemented in other nodes.

@rastart
Copy link
Collaborator Author

rastart commented Oct 30, 2020

FCSdtnode updated with dropdown part list selection

@rastart
Copy link
Collaborator Author

rastart commented Nov 29, 2020

added read sketch node!
The sketch geometry is converted in polylines by freecad 'discretize' function and passed to verts/edge data.
Added a resample function with a parameter 'max_points' that set the max number of point in relation to the max length in the sketch geometry.

fcnodes_sketch

 line - circle - arc conversion from Fc sketch to sv curve
still to add ellipse and conics
to get a correct position of the sketch in blender, the sketch placement and parent body placement are applied on original sketch geometry
node to read/write freecad spreadsheet data
@rastart
Copy link
Collaborator Author

rastart commented Apr 2, 2021

@rastart do you have a freecad 0.19 python 3.9 version? (for blender 2.92) 😄

I confirm last "FreeCAD_weekly-builds-24612-Win-Conda_vc14.x-x86_64" is packed with python 3.9.2!!!!
I'll try it in the next days with blender 2.93
EDIT: it works...

@nortikin
Copy link
Owner

nortikin commented Apr 2, 2021

https://vk.com/wall-35076122_12458 news news news

@nortikin
Copy link
Owner

nortikin commented Apr 2, 2021

exchange index with Gcode node added

@rastart
Copy link
Collaborator Author

rastart commented May 9, 2021

exchange index with Gcode node added
Interesting... I'm looking forward to try this node on my printer!!!

fcstd nodes:
I just fixed some issues with sketch costrution mode reading from sketch read node (freecad 0.2 py3,9 release related), I haven't noticed any other issues.
At this point I think I would add a button to update the nodes manually and keep an autoupdate option.

@rastart
Copy link
Collaborator Author

rastart commented May 22, 2021

added an update button:
update_buttons

I'm already making some little projects with these nodes and I'll make a new repo on github just for project example files (freecad/blender)
the nodes have to be tested and debugged in a freecad/blender workflow, so to improve them It will be required to collect some use cases, once I'll have something I'll share it.

@portnov
Copy link
Collaborator

portnov commented Aug 17, 2021

Hmm
The last node you added is very promising :)
Screenshot_20210817_233226
I do not understand how, but it works somehow :)

Although it appears it has some problems with normals... Or is it just a glitch of "solid viewer"?...

and it could have better handling of situation when the object does not have modifiers.

@rastart
Copy link
Collaborator Author

rastart commented Aug 17, 2021

There is something strange in solid viewer but the result solid is good, I made also some test in freecad.
jar_sv_fcad_workflow
But yes, it works someway...

The approach is this:
1 get the quad edge border
2 subdivide
3 recall the original border and get the center vertex
4 use the border to build a surface patch
5 use the center vertex of the subdivided quads to constraint the surface

patch = F.ActiveDocument.addObject("Surface::Filling","Surface%s"%item) # 4
patch.BoundaryEdges = (com_obj, edge_names) # 4
patch.Points = (CEN, "Vertex1") # 5 THE MAGIC
Before I spotted this point constraints feature in freecad I couldn't get a good translation of the subd patch.

The main problem now is the sorting algorithm I used for the step n3: too many FOR cycles and bottleneck for complex mesh.
Also to sort the edge I used a "coordinates" logic, before I used edge seams but this didn't work totally procedural

About modifier handling we could check if it's there and if not add one by script and remove it.

@MisterMakerNL
Copy link

This is such good stuff, I hate to see it go to waste because people can't find it or already give up on installing. So please merge it!

@luzpaz
Copy link
Contributor

luzpaz commented Apr 9, 2022

Thanks for all the effort to get this working thus far.
Question: what is blocking this branch from being merged?

@nortikin
Copy link
Owner

I want to merge this. How do you do?

@nortikin nortikin merged commit 6b09bd3 into nortikin:master Apr 12, 2022
@portnov
Copy link
Collaborator

portnov commented Apr 12, 2022

Eeh. CI is broken :/

@luzpaz
Copy link
Contributor

luzpaz commented Apr 12, 2022

Screenshot_20220412_121952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants