Author Topic: Erase Construction lines  (Read 268 times)

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Erase Construction lines
« on: March 30, 2018, 03:44:56 PM »
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:
Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 77
Re: Erase Construction lines
« Reply #1 on: March 30, 2018, 04:21:10 PM »
Fixed the first error:
Code: [Select]
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:
Code: [Select]
'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

  • Hero Member
  • *****
  • Posts: 5593
Re: Erase Construction lines
« Reply #2 on: March 31, 2018, 12:15:56 AM »
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

  • Hero Member
  • *****
  • Posts: 2790
Re: Erase Construction lines
« Reply #3 on: March 31, 2018, 12:52:16 AM »

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

  • Jr. Member
  • **
  • Posts: 77
Re: Erase Construction lines
« Reply #4 on: March 31, 2018, 09:36:14 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.

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

  • Hero Member
  • *****
  • Posts: 2790
Re: Erase Construction lines
« Reply #5 on: March 31, 2018, 10:38:16 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

  • Hero Member
  • *****
  • Posts: 881
Re: Erase Construction lines
« Reply #6 on: March 31, 2018, 12:07:33 PM »
Expanding on Lars comment, here's an example. Dunno that regen is necessary after erase. I've forgotten more than I know.

Code: [Select]
>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
« Last Edit: March 31, 2018, 12:13:47 PM by bdeck »

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Re: Erase Construction lines
« Reply #7 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?
Regards,

Jim

Bob P

  • Hero Member
  • *****
  • Posts: 1201
    • Era Replica Automobiles
Re: Erase Construction lines
« Reply #8 on: March 31, 2018, 03:14:05 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

  • Hero Member
  • *****
  • Posts: 5593
Re: Erase Construction lines
« Reply #9 on: March 31, 2018, 10:38:31 PM »
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