PointPicker scripting
All  1-2  3-7

Previous
Next
 From:  Michael Gibson
10802.3 In reply to 10802.1 
Hi Brian,

> Remark: cPlane1 is not a CPlane, it is actually a ptframe. 2D or 3d or pseudo 2D ???

"cplane" and "ptframe" are not distinct object types, they are both instances of a MoiCoordinateFrame object that contains an origin point and x/y/z axis directions forming a coordinate system.

When you access the pointpicker.cplane property, that will return a MoiCoordinateFrame object set to the local cplane for the viewport that the mouse was clicked in. That's the same as the grid you see inside of a viewport.

When you access the pointpicker.ptframe property, that returns a MoiCoordinateFrame object that has the x/y/z axis directions of the viewport's cplane but it's origin point is placed at the picked point. It's the same as if you used pointpicker.cplane but then set the .origin property of that frame to the picked point (pointpicker.pt).

re:
code:
var cPlane2 = pointpicker.ptframe.setBasePt(lastPt); //This code throws error, Not a constructor.<<<<<<<<<<<


So the reason why this throws an error is that you'll be getting a MoiCoordinateFrame object returned back from the pointpicker.ptframe part of the code, and then you're trying to call a function setBasePt on it. But there is no function setBasePt on a MoiCoordinateFrame object, it's the pointpicker that has a setBasePt() function in it.

The pointpicker setBasePt() takes a point in world coordinates to use as the base point for the current pick. Things like straight snap use the base point, it's usually set in things like drawing a line for the 2nd pick of the line. The point from the first pick is set at the base point and that will then set up straight snaps which go through the base point.

Does any of that help? I'm not really sure what it is that you're trying to do at that point in the script so it's a little difficult for me to tell you exactly what the code is supposed to be right there.

But if it's the second point of a picking sequence that is meant to behave like the line command with straight snaps active from the previous point pick, that's what you would use setBasePt() on the pointpicker to set up.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10802.4 In reply to 10802.2 
Hi Brian,

re:
> The following appears to be working the first time through.
> Note, I switched from setBasePt() to setPt().

The .setPt() function on the pointpicker is a way for a script to set the picked point itself. It's something that might be used in a snapping function callback, where some script wants to trigger the point pick to be finished and to have a specific point value.

It's not likely to be relevant to what you're doing.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
10802.5 In reply to 10802.4 
Thank you Michael.
I'll study your responses tonight.
I seem to be making a little bit of progress:-)

- Brian


So I can either convert cPlane1 to cPlane2 with a new base point, which I still do not know how to do.?
cPlane2 needs the same grid, with a new base point.

Or else, I can open a 2nd pointpicker, and feed the new base point to it by script, not by manual pick, and get the cPlane2 from the second pointpicker.ptframe.?

EDITED: 4 Aug 2022 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10802.6 In reply to 10802.5 
Hi Brian,

re:
> So I can either convert cPlane1 to cPlane2 with a new base point, which I still do not know how to do.?

I'm a little confused by your question, are you maybe getting the "base point" for the pointpicker mixed up with the origin point of a MoiCoordinateFrame object? Those are different things.

You can set the origin of a MoiCoordinateFrame object like this:
cPlane2.origin = pt;


> Or else, I can open a 2nd pointpicker, and feed the new base point to it by script, not by manual pick,
> and get the cPlane2 from the second pointpicker.ptframe.?

I may need you to describe a little more about what you're trying to do with cPlane2.

Is the confusing part maybe that you're trying to use cPlane1 and cPlane2 for separate things but they are both referring to the same MoiCoordinateFrame object?

If you want an independent frame try creating a new one using:

var cPlane2 = moi.vectorMath.createFrame();

cPlane2.xaxis = cPlane1.xaxis;
cPlane2.yaxis = cPlane1.yaxis;
cPlane2.zaxis = cPlane1.zaxis;
cPlane2.origin = pt;

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  bemfarmer
10802.7 In reply to 10802.6 
Thank you Michael,

I have been a lot confused.

But your last response about "If you want an independent frame try creating a new one using:"
is exactly what I need for the script!

So the cPlane1.xaxis; and cPlane1.yaxis; and cPlane1.zaxis; are not locked to a specific point in 3D space, because they are Vectors,
but they commonly are thought of as emanating from the local Origin, which is located at the world coordinate point pt.
And the three axes do correspond with the grid axes of the particular View, so the 2D points, (or possibly 3D points), can be plotted.
The world coordinate point pt, will establish the local Origin of the frame. The local Origin point is ( 0, 0, 0 )

My cPlane2 origin will be in a different location than the cPlane1 origin.

Again,
Thank you very much.

- Brian

I should not have been talking about BasePt, when I should have meant origin point.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1-2  3-7