Jump to content

Clipping Cube By Local CSY


---
 Share

Recommended Posts

Hi, I'm trying to create some report pages automatically, usually the way I do this is with the help of a local coordinate system. I set the localcsy as the viewing coordinate system, View Normal to a certain axis, make the elements I want to fit inside the report page exclusive, adapt zoom, make the rest of the mesh visible, snap report...etc.

For one of these views, I would like to clip everything around this local coordinate frame in a say 30mm x 30mm box (x30mm*) box (clipping cube).

I'm trying to use the function:
gom.script.view.set_clipping_parameters
which appears to take a bunch of parameters that defines a frustrum.
The docstring doesn't provide much information (parameters = QVariantMap)

Since I set the Local Coordinate System as the Viewing Coordinate System I can access the "Active" view attributes
(i.e  - gom.app.views.active_frustrum.front_plane.normal )
this seems to set the orientation correct.

But for the life of me I cannot figure out the distance attributes to set the position & size.
I tried feeding in the local coordinate system center then off-setting those values by the bounding box dimension -but that didnt work.
tried accessing the gom.app.views.active_frustrum.front_plane.distance_to_origin, but was having trouble with that as well.

Example:
GOM_Clipping_Cube_example.thumb.png.db981a755bb62f3ee86b191c0d73b9c1.png


Code:

GOM_Clipping_Cube_vs_code.thumb.png.66d23cbdeb7dc15d78d98f657a6fe5b8.png

Any help would be greatly appreciated.
the zeissiqs.github.io page has been a godsent btw.
-Devon
 

Link to comment
Share on other sites

Hi,
I'm not really familiar with this topic, but I tried a few things and made the following observations:

  • Even if gom.script.view.local_csys_for_viewing() is used with a local coordinate system, the frustum's normals still depend on the current view.
  • Therefore, the normals have been created from the local CS axes (instead of using the frustum's normals).
  • The distance is still measured from the global CS origin.

 

image.thumb.png.8032299f08d9b95b9fbc451fe00e5364.png

The local CS was placed at the corner of the "E". The global CS is (additionally) shown at the global origin (the large one without labels).

The clipping has been created with the following script:
 

import gom
import gom_math

gom.script.view.use_local_csys_for_viewing (csys=gom.app.project.inspection['MyCS'])

normal1 = gom.app.project.actual_elements['MyCS'].csys_geometry.direction1
normal2 = gom.app.project.actual_elements['MyCS'].csys_geometry.direction2
normal3 = gom.app.project.actual_elements['MyCS'].csys_geometry.direction3

gom.script.view.set_clipping_parameters (parameters={'clipping_enabled': True,
    'plane_back_distance': 23, 'plane_back_normal': gom_math.Vec3d_mult_scalar(normal3, -1),
    'plane_front_distance': 0, 'plane_front_normal': normal3,
    'plane_bottom_distance': -13, 'plane_bottom_normal': gom_math.Vec3d_mult_scalar(normal2, -1), 
    'plane_top_distance': 30, 'plane_top_normal': normal2,
    'plane_left_distance': 20, 'plane_left_normal': gom_math.Vec3d_mult_scalar(normal1, -1),
    'plane_right_distance': -5, 'plane_right_normal': normal1
})

Maybe there is a step missing which applies the local CS as reference?

Hope this helps anyway!

Best regards,

Matthias

P.S.: Thanks a lot for the positive feedback regarding zeissiqs.github.io - we love to read that!

Link to comment
Share on other sites

Thanks Matthias for the quick response!

Im still having trouble figuring this out,

I think your solution for calculating the normals of the clipping cube is much more elegant, 
I was setting the active view through the script, --> then extracting those values from the active view.
( gom.script.view.use_local_csys_for_viewing + gom.script.view.set_zm
--> get gom.app.views.active_frustum.front_plane.normal )

I think I'm having difficulty because my part is in vehicle coordinates (2000mm away from global csy) and my local frame is at some crazy compound angle relative to the global csy.

I tried simplifying things, and created a local frame with the same normals as the global csy, just translated to my part.
I also offset the X/Y/Z value of this local CSY by roughly 15-20mm in each direction and created 6 parallel planes.
This essentially represents the clipping cube i'm after.
image.thumb.png.60d12617ded7d731004204ea8763ea28.png
When I tried recording this clipping cube while manually viewing from the Z- Direction,
1. it omits the front back distance.. (which I understand why, and is ok)
2. Front/Back= Z, Bottom/Top = X, Right/Left = Y.   (... I think).
3. Top distance is negative, while the bottom distance is positive.(...huh?   My Intuition tells me this would create a clipping cube 3000mm long. )
but I just recorded a 30mm^2 cube.
image.png.8cc25f8c08fbc8f14c33ac24f9b1efd7.png

regardless, I tried to match these values by using the local csy attributes & multiplying one of the values by negative 1.

image.thumb.png.183d0c6b4ce172dd08ed06ed9b6db9cc.png

which worked!
image.thumb.png.f88614f7ec28ed90831fde4af1c0af5a.png
I then chose another local CSY, and it worked as well
image.thumb.png.620cbba5cfc8b2da3f2775d041c7334d.png
but when I rotated the 2nd coordinate frame, it did not. =(

image.thumb.png.fe3bd07a45078844979e0896c4c5d0c4.png

The Normals of the clipping cube look correct, but I feel  like its doing a a rotate translate, vs translate rotate sorta thing (?)
& i'm still not sure why 1 of the distance values = positive and 1 = negative..

Anyways, any sorta feedback is greatly appreciated!
This forum is like a goldmine, I can spend all day reading these threads...
Thank you!

Edited
Link to comment
Share on other sites

 Share

×
×
  • Create New...