News:

Please note new Forum URL: forum.designcad.com

Main Menu

POINTVAL problems

Started by ktk, February 19, 2007, 05:27:39 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

ktk

This is a short macro that demos the problems I am having with the pointval statement. 

I use this as part of a larger macro that needs to find the first point of a solid for point selection to use with solidsubtract.  I normally select the part at 0,0,0 but the user could cut a detail that would remove the point 0,0,0 and then the program can not select the part.

My solution was to use this type of a SubRoutine to find a new point in case 0,0,0 is no longer on the part.  This works fairly well but if you would use a slice by curved surface on the part the Sub no longer works and this is the error message.

Error: The expression in a POINTVAL statement is larger than the number of points currently set.
File:C:....\FindPoints.d3m
Line: 18
Pointval xspt, yspt, zspt,jsp

To test this draw a solid box select the box and run this macro.


Sys(36) = 0  '(1)Turns Off Display UpDate (0) Turns On Display
Sys(800) = 1 '(0)Turns Off Debug Trace(1) Turns On Debug Trace


For jsp = 1 to Sys(80)
getselect jsp, ent
entity ent
Type = Sys(90)
SolidNo = Sys(95)
NoPoints = Sys(99)
Message "Picked item ",j, " is entity ", ent,"Type =",Type
Message "For entity ",ent," No of Points is ",NoPoints
' get first points into SelectPoints, xspt, yspt, zspt
If SolidNo > 0 Then
  Message "Solid Found: Type = ",Type, "Solid No = ",SolidNo
  GoTo FoundSolid
End If
Next jsp
FoundSolid:
Message "jsp = ",jsp
Pointval xspt, yspt, zspt,jsp
Message "Point No ",jsp,"Points Are ",xspt, yspt, zspt

Then using solid subtract remove some parts of the solid. Run the macro after each modification.  Try the lower left corner and then the upper right corner.

Then draw a circle (as a line) that cuts thru one edge of the part. Extrude this line such that it passes thru the front and back of block then do a slice by curved surface. Remove the cut piece and the origional circle and the surface to leave the block with a bite out of one edge.  No run the macro and watch the results.

Any help will appreciated

Keith



ktk

prl  I have used 1 as the point to select but the message is still the same.  In fact after reading your reply I change the macro and added this section.

FoundSolid:
entity ent
Type = Sys(90)
SolidNo = Sys(95)
NoPoints = Sys(99)
Pointval xspt, yspt, zspt,1
Message "Point No ",NoPoints,"Points Are ",xspt, yspt, zspt
SolidNotFound:
If SolidNo = 0 Then Message "did not find solid"
End

This still has the same error message.  What I fail to understand is that as I add detail to the solid and when viewed in point select mode there are many points the enity statement finds fewer points than when the part was first drawn.

DrollTroll

First of all, check your entity type.

Sys(99) does not represent a point count for all possible types of entities. For a grid header (entity type 32) it's the number of grid lines (entity type 33) contained in the grid. For a group (entity type 34) its the number of entities in the group.

Any editing operation that cuts a grid breaks it into two or more smaller grids, and may also generate some individual planes. So if you're entity is a grid header, its quite possible that the number of grid lines could change after any given solid operation.

If you've got the Developers Toolkit (any version) check how the sample MakeXYZ macro handles different entity types. That may give you a little more insight into what's going on.
25 years with DesignCAD

ktk

DT 

If you look at the macro you can see that I only accept and work on a solid. In fact in the sample macro you need to select the entity before the macro runs.  The first thing it does is check the Sys(95) for a solid no and entity type 32.

ktk

The final solution to my problem tho not perfect works for most cases.

DT's suggestion to look for grid points eliminated the error message but the points that resulted from reading the grid points would not work for point selection as they were not within the bounds of the solid part.

What I did was add a Error handling routine that intercepts the Error and sends a message to the user that they will need to manually solid subtract after the macro is finished.

I can remove all 4 origional corners and still find the part for solid subtract.  Then if I use slice by curved surface to remove a part of the solid and again test the macro it will fail and I get the message that I will need to manually solid subtract.  Now the real interesting part is that after manually preforming the solid subtract the macro can now again perform solid subtracts without user intervention.

This is the subroutine that I am using now.

GetSelectionPoints:
'DeSelect to make sure there is no Selection Made before Starting SubRoutine
If sys(80)=0 then GoTo SkipDeSelect
>DeSelect
{
}
SkipDeSelect:
'Select everything on Part Layer'
>SelectAll
{
  }
For jsp = 1 to Sys(80)
getselect jsp, ent
entity ent
Type = Sys(90)
SolidNo = Sys(95)
NoPoints = Sys(99)
'Message "Picked item ",j, " is entity ", ent,"Type =",Type
'Message "For entity ",ent," No of Points is ",NoPoints
' get first points into SelectPoints, xspt, yspt, zspt
If SolidNo > 0 Then
  'Message "Solid Found: Type = ",Type, "Solid No = ",SolidNo
  GoTo FoundSolid
End If
Next jsp
FoundSolid:
On Error Goto handler
'Message "jsp = ",jsp
Pointval xspt, yspt, zspt,jsp
'Message "Point No ",jsp,"Points Are ",xspt, yspt, zspt
Return

handler:
If DetailType < 8 Then Message "Error Finding Part Subtract Solid Manually"
Resume

I could write a separate macro to demo this if there is some interest but the detail macro that uses this sub is not a stand alone and requires the K2WoodShop to function.

Thanks for the input it was the help I needed to make progress in my program.
Keith


ktk

Yes you are right about the point no.  The reason it works in my program is that there is only 1 enitity on the active layer.  I looked back at my older code and I used 1 as the index to the point not jsp.  I'll switch that back so it makes more sense.

Keith

DrollTroll

ktk, I think you're still experiencing some confusion over "entities" vs. "solids". A solid can consist of multiple entities. For example, if you draw a 3D Box, that solid consists of five entities: two planes, a grid header, and two grid lines.

So when you select a grid entity, the Entity statement will fill in the sys(9x) values, but won't actually set any points. You should see this to be so if you check Sys(1) after the Entity statement -- if it's zero you've probably selected a composite entity (symbol, block, grid header, group).

Let's assume you've selected a simple 3d Box. Here's the way it will look from BasicCAD's point of view:

Sys(80) = 5
Assume GetSelect gives you the following entity ID's in this order:

1, 2, 3, 4, 5

As you run Entity on each ID in turn, you get something like this:
Entity 1
Sys(90) = 31(plane)
Sys(99) = 5 (five points -- corner1, corner2, corner3, corner4, closing point back at corner 1)
Sys(1) = 5 (Entity statement on a plane sets the points in memory)

Entity 2
Sys(90) = 31(plane)
Sys(99) = 5 (five points -- corner1, corner2, corner3, corner4, closing point back at corner 1)
Sys(1) = 5 (Entity statement on a plane sets the points in memory)

Entity 3
Sys(90) = 32 (grid header)
Sys(99) = 2 --> Means two grid lines to follow, not two points! The next two entities will be grid lines.
Sys(1) = 0 --> Grid header has no actual points

Entity 4
Sys(90) = 33 (grid line)
Sys(99) = 5 (five points -- same points as first plane, generally speaking)
Sys(1) = 5 (Grid lines have points so Entity statement sets points in memory again)

Entity 5
Sys(90) = 33 (grid line)
Sys(99) = 5 (again, five points matching one of the planes)
Sys(1) = 5

The actual ordering of planes vs. grid headers may vary after you've done some solid operations, but the grid lines should always follow the grid headers in ID sequence.

I hope that clears things up just a little...
25 years with DesignCAD

ktk

Prl My macro knows exactly where the 3d box is drawn, how long, wide and deep it is. It is stared at 0,0,0 and thats what the program uses to gravity select the box.  The problem is that the user thru the program or other operations can use a slice or solid subtract and eliminate the point at 0,0,0 and this the macro has no way of tracking.  So I have been trying to develop a way of placing points into the macro programatically.  Reading DT's description of the enities that make up a 3d box the points I am trying to find are on the planes.

As I said in my earlier post the macro works 90% of the time and I am satasified thats all I'll get.

ktk

Well I just couldn't give up and I finally fixed my macro for finding selection points after a slice by curved surface.  It involved adding a check to see that the points found by the pointval statement were within the bounds of the object I was trying to select.  (DT I call the box an object because as you have shown me it contains many enities).

Thanks everyone for your suggestions and help.

Keith