Author Topic: >pointselect observation  (Read 4883 times)

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
>pointselect observation
« on: August 22, 2013, 06:34:56 AM »
Never had much luck when using the >pointselect command.  It routinely fails to select the entity at the point specified sometimes selecting something in distant 3d space.

Running a few experiments by flipping around the visual orientation of the drawing/model leads me to believe this command is influenced by the 2d or 3d selection mode setting.  Why this would be puzzled me since I'm tellling the command the specific x,y,z coordinate of the item to be selected.

So for kicks, programmatically, if I switch to a 3d selection mode, the command appears to select the item at the specified x,y,z location as it should.


.
.
.
sys(80)=0

>3dSelectMode
{
}

>pointselect
{
  <type 0
  <pointxyz [wo/2, 1, wd/2]
}
.
.
.



Something to keep in mind while I test this further.




Lar

  • Hero Member
  • *****
  • Posts: 2513
Re: >pointselect observation
« Reply #1 on: August 22, 2013, 05:42:13 PM »
This is normal dcad behavior ever since they introduced 2d select mode. 2d select mode selects the oldest (the one created first) qualified item  on the entity list (my interpretation).

Back in the dos days there was only 3d select mode, which is extremely frustrating to use manually but I'm glad they kept it around for purposes such as yours.

Lar

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: >pointselect observation
« Reply #2 on: August 23, 2013, 02:36:02 AM »
Just regurgitating something I read here (probably it was one of you gentlemen that said it lol),  but one way to change the "age/seniority" of entities is :-

a. suppose you select the wrong entity where several meet at a point, (and I agree it will be the oldest one at that point that it selected, assuming you haven't used "some layers inactive", or "filtering" etc), then
b. delete it with "Del"
c. then replace it with Ctrl+Z
d. it returns with zero seniority (newest entity in the drawing),
e. and next time you select something meeting at that point, it will be something else, (the NEW oldest entity) -  hopefully the one you want.
(2 cents)
« Last Edit: August 23, 2013, 03:03:38 AM by samdavo »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #3 on: August 23, 2013, 04:47:36 AM »
This is normal dcad behavior ever since they introduced 2d select mode. 2d select mode selects the oldest (the one created first) qualified item  on the entity list (my interpretation).

This isn't normal at all.  You don't need to switch to 3d mode when using the >line command or any other command where you are specifically setting points.   The pointselect command is a programming command, it shouldn't depend at all on the viewing angle.

And to be clear, the command should select the item at the 3d point specified, not something that is projected halfway across 3d space because of the 2d screen viewing angle.


Edit:  all this because BasicCAD is very poor at programmatically selecting solids or doing additions and subtractions with code.  The need to set points on solids to select them is a pain.
« Last Edit: August 23, 2013, 05:19:04 AM by prl »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #4 on: August 23, 2013, 08:15:48 AM »
a. suppose you select the wrong entity where several meet at a point, (and I agree it will be the oldest one at that point that it selected, assuming you haven't used "some layers inactive", or "filtering" etc), then

Sam, my issue isn't with entities sharing the same edge (that's a pain I agree), it is with the pointselect command selecting something that isn't even near the point specified. 

Lar

  • Hero Member
  • *****
  • Posts: 2513
Re: >pointselect observation
« Reply #5 on: August 23, 2013, 11:09:07 PM »
This isn't normal at all.  ...
...
And to be clear, the command should select the item at the 3d point specified, not something that is projected halfway across 3d space because of the 2d screen viewing angle.
Sorry, Prl, but this is how selecting works while in 2d select mode. For the convenience of not having to march the cursor in 3 dimensions to a desired vertex we pay the price of not being able to be specific in ambiguous circumstances. There are a few solutions to this: 3d select mode, orbiting the screen, layer or color filtering, etc...

Edit:  all this because BasicCAD is very poor at programmatically selecting solids or doing additions and subtractions with code.  The need to set points on solids to select them is a pain.
I wouldn't blame this on basiccad since we have the same issues when doing boole operations manually. Version 23 attempts to improve this with the "selected only" option (which is not really an option since there is no dialog box to activate/deactivate anything) but on my machine I get a string of error messages if stuff is selected when I invoke a boole command (except the slices, which have dialog boxes). I gave up on using macros for booles a very long time ago because of the need to click on entities and no way of guaranteeing what is selected. Your solution of using 3d select mode may reopen that door for me.

Lar
« Last Edit: August 24, 2013, 05:58:09 AM by Lar »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #6 on: August 24, 2013, 03:37:48 AM »
Sorry, Prl, but this is how selecting works while in 2d select mode.

Where would you expect the below line to be drawn?

>line
{
<pointxyz [0,0,0]
<pointxyz [0,10,10]
}

You would expect from (0,0,0) to (0,10,10) regardless of what viewing angle your drawing is at.  In other words, has nothing to do with 2d or 3d (user) screen selection mode since we aren't using the screen for setting points, we are using basicccad to set the points.

Similarly,

I expect

>pointselect
{
<type 0
<pointxyz [0,0,10]
}

to select the item at (0,0,10) regardless of my viewing angle or whether I'm in 2d or 3d user selection mode.  In basiccad, we are purposely not using the screen for determining point locations or selecting, we are using the model's 3d space coordinates.


Edit:  I added a few graphics.

If we are visually selecting items (using the screen), we all agree that when using 2d mode if we were to put the cursor at the end of the black arrow in graphic 1, it should select the red cube.

But programmatically, if I specify the selection point at the end of the black arrow in 3d coordinates, regardless of my viewing angle it should always select the blue cube.  The graphic 2 is an isometric view of the two cubes showing their actual relationship and the location of the arrow head location.
« Last Edit: August 24, 2013, 04:26:03 AM by prl »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #7 on: August 24, 2013, 03:45:40 AM »
I gave up on using macros for booles a very long time ago because of the need to click on entities and no way of guaranteeing what is selected. You solution of using 3d select mode may reopen that door for me.

Yes, very difficult to cycle the drawing database and do things with solids.  We need tools like>SelectSolidById  and >SolidAddById and a few sys functions that tell us the last solid id created etc.
« Last Edit: August 24, 2013, 08:44:20 AM by prl »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #8 on: August 24, 2013, 03:52:32 AM »
Getting back to the >pointselect command,  I wonder what the "range" is when setting a point in 3d space that isn't near or on an entity?  As we know, gravity snap has an infinite 3d space range whereas line snap uses a 2d screen projection pixel range.

dcadRob

  • Hero Member
  • *****
  • Posts: 688
Re: >pointselect observation
« Reply #9 on: August 24, 2013, 07:05:34 AM »
Quote
Yes, very difficult to cycle the drawing database and do things with solids.  We need tools line >SelectSolidById  and >SolidAddById and a few sys functions that tell us the last solid id created etc.
Can't you just name the solids and then use the name to make selections?

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #10 on: August 24, 2013, 07:23:59 AM »
Can't you just name the solids and then use the name to make selections?

Ideally programmatically we should be able to say subtract solid named "hole_type 1" from solid named "plate_blank" and dispense with setting points on the solids but currently we are forced to find the solid in order to find a point on the solid for use with the various commands . . . . and then hope the point isn't a shared edge.   As Lar mentions, version 23 tries to help but still a hassle.

Lar

  • Hero Member
  • *****
  • Posts: 2513
Re: >pointselect observation
« Reply #11 on: August 24, 2013, 07:37:44 AM »
I gave up on using macros for booles a very long time ago because of the need to click on entities and no way of guaranteeing what is selected. Your solution of using 3d select mode may reopen that door for me.

Yes, very difficult to cycle the drawing database and do things with solids.  We need tools like >SelectSolidById  and >SolidAddById and a few sys functions that tell us the last solid id created etc.
Yea, I've longed for such tools for a long time. Instead we have to use layer tricks to pinpoint the required solids, or move them away from everything else, do the boole, then move the new booled solid back.

The thing is, there is no way to easily and reliably identify 2 solids, by clicking points, in all circumstances. Even if the 2 solids are the only things in the drawing it is possible to pick the same solid twice.

Now if you are willing to take the easily out of the equation here's a method:
  Before running the macro: 1] select the two solids...     
In the macro: 2] get the solid id numbers of the 2 solids then deselect them,
3] switch the view to top, 
4] get the bounding box of the entire drawing,
5] draw a 3-point plane somewhere outside and far away of the bounding box on one side of everything else. Record point-1 of the plane and give this plane the solid id of one of the solids (select it with sys(9) and record its entity id ),
6] Draw another plane on the opposite side of the drawing and follow step-5 for this plane and the other solid,
7] Now you can run the solid boole command and click at point 1 of the two planes to choose the 2 solids.
8] Get the solid id of the new booled solid and use getattr and putattr to remove the solid id from the two planes of the new solid and delete them. <<edit: actually, I'm not sure if their entity ids would change so you may use v23's 'long entity id', or: select the solid by clicking at one of the outside planes, solid exploding, selecting previous (to get all the components selected again), click at the 2 outside planes to deselect them, and finally solid defining the remaining selected components... remember - we removed easily from the equation>>

Make sure to create planes (rather than lines or anything else) in steps 5 and 6. In boole commands dcad identifies the nearest plane or grid surface at the location of the set point (whether the non-surface is a part of a solid or not) so, if the macro clicks at non-surfaces then the nearest surface of another solid may be chosen.

This is a lot of coding for one boole operation (far easier to simply do the boole manually). I would use such a macro for a batch of booles, in which case the solids would have to be selected one at a time, during the running of the macro, to get the solid id's in order of how the pairs would be booled.

Lar

« Last Edit: August 24, 2013, 08:05:30 AM by Lar »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #12 on: August 24, 2013, 11:40:03 AM »
.
.
7] Now you can run the solid boole command and click at point 1 of the two planes to choose the 2 solids.
.
.

Lar, thank you for the write-up.  That is very clever and resourceful thinking.  I wonder if I can exploit your idea and take a pointmark and with putattr assign it to the solid making an improper solid of sorts with the pointmark in deep space by itself.  This way I could cycle all the solids and say solid 52 would have a pointmark assigned to it at say -10000,52,0, solid 63 would have a pointmark assigned at -10000, 63,0 etc.  This way I would always know how to select a solid for Boolean operations, get the solidid and then -10000,solidid,0 will give me a free and clear snap point. In the past I've noticed Boolean operations would "eat" the improper part of the solid.

Let me try this manually.


Edit:

Well the pointmark idea only works to select the entity. But SolidAdd and SolidSubtract will not honor them though.

Rather than using the pointmark, however, if I use an improper plane (prl terminology, a plane with three points with the first two at the same location), that will work.

So in summary, say you want to programmatically solid subtract solid #38 from solid #109. 

1.  create an improper plane at -10000,38,0 and solid define it with solid #38.

>plane
{
<pointxyz [-10000,38,0]
<pointxyz [-10000,38,0]
<pointxyz [-9999,38,0]
}
getattr sys(9), type, select, laynum, groupid, red, green, blue, solidid
putattr sys(9), type, select, laynum, groupid, red, green, blue,38


2.  create an improper plane at -10000,109,0 and solid define it with solid #109

>plane
{
<pointxyz [-10000,109,0]
<pointxyz [-10000,109,0]
<pointxyz [-9999,109,0]
}
getattr sys(9), type, select, laynum, groupid, red, green, blue, solidid
putattr sys(9), type, select, laynum, groupid, red, green, blue,109


3. then

>SolidSubtract
{
<pointxyz [-10000,38,0]
<pointxyz [-10000,109,0]
}


clean up should be automatic, DesignCAD removes the improper planes.
« Last Edit: August 24, 2013, 03:06:05 PM by prl »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: >pointselect observation
« Reply #13 on: August 24, 2013, 03:35:49 PM »
Can't you just name the solids and then use the name to make selections?

1.  create an improper plane at -10000,38,0 and solid define it with solid #38.

>plane
{
<pointxyz [-10000,38,0]
<pointxyz [-10000,38,0]
<pointxyz [-9999,38,0]
}
getattr sys(9), type, select, laynum, groupid, red, green, blue, solidid
putattr sys(9), type, select, laynum, groupid, red, green, blue,38

2.....
thanks gents,

prl,
One of these days you're gonna have to add some more commentary to explain each step.
At least the sequence above makes it clear how to give an entity an "ID",  which I assume is the same as a name. 

PS what do you mean please "clean up should be automatic, DesignCAD removes the improper planes."?

PS Haven't understood all of the above, but I not your plane has two points the same - so that's what makes it "improper?"
 
« Last Edit: August 24, 2013, 03:42:47 PM by samdavo »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: >pointselect observation
« Reply #14 on: August 24, 2013, 05:26:28 PM »
Sam,

This is some off-the-wall trickery I'm doing so it isn't going to be easy to follow.  Lar can follow the trickery since he is good at inventing crazy things like this too plus we've both been at this for a while.

Solids don't have unique names but they do have solid ids which for basiccad are integers.  I'm tricking DesignCAD into working with solid ids by adding a short piece of line (the improper plane) to each solid at some unique location in what I call "deep space" (nothing else exists there).  Think of each solid as having a detached selection tag.  I'm purposefully ensuring these selection tags are always in a unique location that I can easily find.  These selection tags are stacked vertically (Y coordinate) like rungs on a ladder in deep space.  To get solid number 33 to be added to solid 69 (these are just example numbers), I tell the DesignCAD SolidAdd command to select each solid by putting a point on rung 33 and rung 69.   I'm doing the "telling" with the Y coordinate.

Clear as bentonite?
« Last Edit: August 24, 2013, 05:32:01 PM by prl »