ClientGraphics question

ClientGraphics question

Brett.G
Enthusiast Enthusiast
347 Views
2 Replies
Message 1 of 3

ClientGraphics question

Brett.G
Enthusiast
Enthusiast

I'm trying to make a rectangle appear on a face when a user selects a face (a bounding box for a hole pattern).  I'd like this rectangle to be on the same plane as this face, but I'm not sure how to accomplish this for all cases.  For example, I can make a square and show it on a face that is on the X-Y plane without issue.  However, when I select a face that is the X-Z plane for example, I only see the top edge of the rectangle.  

 

Is there a way to rotate/transform the rectangle to show correctly on the X-Z plane or any other selected plane?  

0 Likes
348 Views
2 Replies
Replies (2)
Message 2 of 3

CadUser46
Collaborator
Collaborator

Brett.  I have never tried this but i can throw out a few ideas that might help you.

 

I would approach this by selecting a face then running the code, or running and waiting for the user to select the face.  I'd use the selectset method then read the properties of the face object into some variables.  You'll then create your sketch using the properties retrieved from the selected face.

 

You might also accomplish this by first calling the createnewsketchcmd (likely not the exact syntax), having the user select the face, then again retrieving the  properties from the sketch.

 

I'd also have to ask if you plan for this sketch to be centred around the origin?  It would be less versatile. 

Or do you plan on it being centred on the face?  If so you'll need to read the properties of the face, the orientation, and do some sums to translate the centre.

 

Alternatively call createsketchcmd then centrepointrectanglecmd, set the two dims, then exit sketch.

 

Craig.


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 3 of 3

Brett.G
Enthusiast
Enthusiast

Thanks Craig.  I think that will be similar to the strategy that I go with.  I'm also trying to have the client graphics (bounding box for hole pattern) follow the mouse until the user clicks somewhere in the sketch for placement.

 

- Run macro

- User selects face

- sketch is created on face

- then I can make use of the SketchToModelTransform or ModelToSketchTransform method of PlanarSketch to get the transformation matrix

- Apply the transform to the graphicsNode of the client graphics to orient the client graphics correctly

 

Then hopefully, the client graphics will be in the correct orientation with respect to the sketch plane.  I'm still working on this aspect and just don't think I'm applying the transforms properly.   Once that is working nicely, then the user can select placement within the sketch to place the hole pattern.  

0 Likes