News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Erase Construction lines

Started by Gymbo, March 30, 2018, 03:44:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gymbo

I use a lot of construction lines sometimes and find it a pain to select them to delete them. Copying the Delete Entity post I wrote this:
Include "dcadalias.d3i"
Alias ENT_SELECTED &H010C
for i = 1 to Sys(9)
>deselect
{
}
getattr i,t
if t = 68 then putattr i,t,1
>erase
{
}
next

regen


And it doesn't work correctly, first I get an error "Error executing DesignCAD command - erase ID:10111", then it deletes all but 1 of the lines then I get another error:
The entity number was out of range....
Line: 8
getattr i,t

Any help will be appreciated.
Regards,

Jim

Gymbo

Fixed the first error:
Include "dcadalias.d3i"
Alias ENT_SELECTED &H010C
for i = 1 to Sys(9)
>deselect
{
}
getattr i,t
if t = 68 then
putattr i,t,1
>erase
{
}
endif
next

regen


and this gives the exact results:
'Include "dcadalias.d3i"
'Alias ENT_SELECTED &H010C
for i = 1 to Sys(9)
' >deselect
' {
' }
getattr i,t
if t = 68 then
putattr i,t,1
>erase
{
}
endif
next

regen
Regards,

Jim

Dr PR

Jim,

I also use many reference lines in my drawings - not the DesignCAD "construction lines" but just normal lines (vectors). As you have noted it is difficult to select and delete construction lines, and that makes them pretty much useless for me.

I put all of these reference lines on separate layers so it is easy to display/hide/delete them.

Phil
DesignCAD user since 1987

Lar


Gymbo,

I'm not sure if your 2nd code in your 2nd post means that you solved your 2nd issue, but in case it doesn't...

When ever you are deleting entities in a for/next loop you have to be careful using "...to sys(9)" because as stuff get deleted sys(9) is being reduced and each loop is not actually going to sys(9), it is going to what sys(9) was valued when the macro encountered that line of code. At some point you will reach the current sys(9) and if anything was deleted the for/next would have more iterations to go and that's why you get that "out of range" error (ie, it's looking for an id higher that the highest id, so it's out of range).

What you can do is, right before the "next" line put "if i=sys(9) then exit for". That way each iteration will do what it has to do then check to see if it should continue of halt.

Also, since when you delete something all id's that preceded also drop, if there are 2 construction lines back to back, the 1st will get deleted but the 2nd won't, because it now has the id of the iteration that is in progress so the next iteration will find the entity after it.

One solution to that situation, both situations in fact (so there will be no need fot the "exit for"), is to use the for/next loop to just select the construction lines, then after the loop use one >erase to delete everything selected. The reason this would work is because when putattr selects something it doesn't deselect what is already selected (which in itself can cause all kind'a messes when you unaware).

Lar

Gymbo

Quote from: Lar on March 31, 2018, 12:52:16 AM
I'm not sure if your 2nd code in your 2nd post means that you solved your 2nd issue, but in case it doesn't...

No it didn't.

Quote from: Lar on March 31, 2018, 12:52:16 AM
One solution to that situation, both situations in fact (so there will be no need fot the "exit for"), is to use the for/next loop to just select the construction lines, then after the loop use one >erase to delete everything selected. The reason this would work is because when putattr selects something it doesn't deselect what is already selected (which in itself can cause all kind'a messes when you unaware).

Lar

Good information and solution to the problem. That's why >deselect was used in the Delete Entity post, I wondered.
Regards,

Jim

Lar



Quote from: Gymbo on March 31, 2018, 09:36:14 AM
That's why >deselect was used in the Delete Entity post, I wondered.
Maybe that is why, who knows... but whatever got selected also got deleted, right... so nothing would be selected when the next iteration comes around. ???

Sometimes I leave unnecessary code "just in case".

Lar

bdeck

#6
Expanding on Lars comment, here's an example. Dunno that regen is necessary after erase. I've forgotten more than I know.


>deselect
{
}
for i = 1 to Sys(9)
getattr i,t
if t = 68 then
putattr i,t,1
endif
next
if sys(80)>0 then    ' prevent error message if no items are selected
      >erase
      {
      }
endif

Gymbo

I like the sys(80) addition, makes a lot of since. Without regen there are ghosts on the screen.

Speaking of forgetting more then you know, off topic. I used the DOS version of DesignCAD a long time ago, and I remember something special about Layer 0, current info is that its used for symbols, was that the same?
Regards,

Jim

Bob P

Quote from: Gymbo on March 31, 2018, 01:53:24 PM
I like the sys(80) addition, makes a lot of since. Without regen there are ghosts on the screen.

Speaking of forgetting more then you know, off topic. I used the DOS version of DesignCAD a long time ago, and I remember something special about Layer 0, current info is that its used for symbols, was that the same?
If I remember correctly, if you insert a symbol that's in layer 0, it will take on the current layer.

Dr PR

There was another "special" thing about Layer 0 in several older versions.

A bug in the Solid Boolean operations (especially Solid Add and Solid Subtract) would cause some of the facets of grids to be moved to Layer 0, and the material would become "Aluminum" (material 0). Part of the resulting solid would be on the original layer and part on Layer 0. This was extremely annoying, and the bug persisted for many years and many versions.

If Layer 0 was disabled you could no longer select the solid, and if you viewed it with shading some of the facets would be missing - holes in the solid.

If you opened the Layers dialog you would see Layer 0 was occupied.

The fix was to click on "Unlock All"in the Layers dialog. This allowed you to select the fragmented solid (even though parts were not visible) and move all of the parts to the desired layer. You could also assign the desired material to all of the solid.

Because of this bug I never place anything on Layer 0. If something appears there I know it is because of the bug, and it is fairly easy to fix.

I am not sure if this bug has been fixed in V26.

Phil
DesignCAD user since 1987