Jump to content
Sign in to follow this  
Alex

Python code for extracting points from curve

Recommended Posts

hello to everyone,

i am trying to make a code to extract point from multiple frames and translate these to x,y,z coordinates.

the first thing that i tried is to use the connect window and then use as input file my python code and as input geometry my multiple frames but it doesn't work.

does anyone have any tips for me?

Share this post


Link to post
Share on other sites

Hi Alex,

Sounds like you only want to save the translated points to a file. Therefor I would go for a feature definition writing the coordinates into a file. In the documentation you can find the chapter "Features | File I/O" and "Features | Introduction" (if writing feature definitions is new for you). 

If you need to use your python code, make sure that the application of the connector is setup correctly. For Python I would recommend to use a shell as application (bash on linux, powershell/cmd on windows) wich is calling python then.

Best

Carl    

Share this post


Link to post
Share on other sites

Hi Carl,

thanks for the tips. 

With this i made a code in feature definitions to get the x,y,z coordinates of a single line, but i want to do this for multiple lines in a section Group.

how do i explode a section group, because i can't GetObject the section group.

and how do i run through multiple lines to get the coordinates.

point_extraction.fdf

Share this post


Link to post
Share on other sites

Hi Alex,

If you need to use a sectionGroup as source you can access the sections via .getSections(). But a section of a section group is no smooth curve, it is of type FOffset wich is in principle a polyline. And a polyline holds a number of points you can access by .getData() . To go through these points:

objectlist seclist(secgroup.getSections()) 	# put sections in a list
foreach(foffset sec in seclist) 		# looking for each element of type foffset inside seclist
  objectlist veclist(sec.getData()) 		# put point data (fvector3) into a list
  foreach(fvector3 pos in veclist) 		# go through point data
    file.writeLine(\
      pos.getX().toString("f",5) + "\t" + \
      pos.getY().toString("f",5) + "\t" + \
      pos.getZ().toString("f",5))
  endfor
endfor

Please check out the type documentation in CAESES to understand the different types.

What is the source of your frames? Maybe there is a more elegant way to get data from you geometry.

Best,

Carl

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...