[Plugin] Position Explorer (Update 12 Feb 2010)
-
Update 12 Feb 2010
Change log
- added ability to get the global positon of vertices in groups/components (1st instance only)
- improved formatting of output
- added vertices only option
A key new feature is the ability to find the global position of vertices that are inside unopened and/or nested Groups/Components. As an example, if you create a cube then Group it, and you have a plugin that tries to get the position of the vertices using .position, the results will be relative to the Group (local space), not the model (global space). This plugin has a feature which can find all parent Groups/Components and stack their Transformations onto the vertex position to get the global position.
===============================================================
As I have struggled up the learning curve on writing SU plugins, I discovered that understanding how SU computes the location of things is quite complex! For instance, you might have a Group of objects, and that Group may be nested in another Group. Each Group has Transformations, and if you open a Group you get "local" positions! Then you have scaling, rotation...
This plugin is really just a tool for developers to explore the position of objects in real time. You right-click (context-click) on an object or objects, and it will run a report to the Ruby Console. It has helped me to learn about the inner workings of SU.
All functionality is accessed through the context menu, and the output goes to the Ruby Console. Currently there are four choices:
- Position Report (position information about selection)* Position Report Recursive (includes all nested objects in selection)* Position Report Recursive, No Faces (same as previous but Faces are skipped to reduce duplicate vertices)* Position Report Detailed Recursive (provides additional details besides position)
Here is a excerpt from a sample Position Report Recursive:
****** Begin Position Report Thu Feb 11 22:04:00 Eastern Standard Time 2010 *****
Options: Recursive(true), Faces(true), Detail(false)#Sketchup::Group:0xcdf4b10; ID:146; Name=; contains 19 entities
Group Transformation:
1.0 : 0.0 : 0.0 : 0.0
0.0 : 1.0 : 0.0 : 0.0
0.0 : 0.0 : 1.0 : 0.0
14.1858552430346 : 28.7146355916016 : 0.0 : 1.0
Entities in Group ID:146:
#Sketchup::Edge:0xcdcdcd8; ID:138
Vert ID:97 [0].position = (20.435683", 40.376235", 0")
Vert ID:122 [1].position = (20.435683", 40.376235", 3.61414")
#Sketchup::Edge:0xcdcddb0; ID:131
Vert ID:93 [0].position = (9.152105", 40.376235", 0")
Vert ID:118 [1].position = (9.152105", 40.376235", 3.61414")*(Note: The formatting doesn't show up well here)
I'm finding that the recursive feature really helps to understand the relative position of objects in groups and components. Try creating a box, group it, then create a second box and create a new group of the first and second boxes, then experiment with opening the top group, then the nested group, and checking positions.
Be careful with using recursive mode on objects with many entities! It will report on EVERY face, edge and their associated vertices.
More features are planned, including formatted reporting and saving to a file.
Let me know what you think.
Glenn
- Position Report (position information about selection)* Position Report Recursive (includes all nested objects in selection)* Position Report Recursive, No Faces (same as previous but Faces are skipped to reduce duplicate vertices)* Position Report Detailed Recursive (provides additional details besides position)
-
Yea - the swap between local and global position as you open and close grops/components can bite your in the rear end some times.
Sounds like an interesting tool. -
I know one thing that adds to the confusion is that when you have a Group open for editing, the positions are reported relative to the Global axes, and not the Group's axes.
-
@jim said:
I know one thing that adds to the confusion is that when you have a Group open for editing, the positions are reported relative to the Global axes, and not the Group's axes.
Yes, that was driving me crazy with SketchyFFD. I'd open a group and check positions through the Ruby Console, then put that code into a plugin and watch it act completely differently! Once I figured out what was causing that, I was able to fix it, but it was still hard to visualize, especially with nested groups/components.
Glenn
-
Update 1 posted, see top of thread.
Glenn
-
Hi, I have a question about the positions / coordinates within sketchup. I am not a software engineer/ programmer, but I have an idea of which I want to check the technical feasibility. I want to build a model with standardised components using SketchUp 7 (free version). In these components I added a CPoint.
When I have built my project with the components, I want to extract all the following data:
Componentname Componentrotation Globalposition of CPoint X, Y, Z (projectposition. 1 component can have multiple instances. I want to extract every single instance with its own unique position)Can you tell me: Can this be done? (and if not, do you have any suggestions?)
-
@j.park said:
Hi, I have a question about the positions / coordinates within sketchup. I am not a software engineer/ programmer, but I have an idea of which I want to check the technical feasibility. I want to build a model with standardised components using SketchUp 7 (free version). In these components I added a CPoint.
When I have built my project with the components, I want to extract all the following data:
Componentname Componentrotation Globalposition of CPoint X, Y, Z (projectposition. 1 component can have multiple instances. I want to extract every single instance with its own unique position)
Can you tell me: Can this be done? (and if not, do you have any suggestions?)Search for 'Transformation'...
You get the cpoint's position in the definition, then get each instance's transformation, then transform the cpoint's position by that instance's transformation - this gives you the location in the model of the cpoint that's in that instance... Ifinstances are inside another container [group/instance] other than the model you need to get their transformations too and apply them 'combined' tr1 * tr0 etc [in reverse order].
Repeat for each of the definition.instances
There are also ways of getting an instance's rotation from its trasformation. -
Glenn, Thnx!
This script was really helpful to me and instructive too!
Advertisement