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.

Hatch area, need help.

Started by GooPie, February 24, 2015, 11:11:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GooPie

Hello,

For my work, I import cadastral plans to DXF formats in DesignCAD .

I then 2 layers:

In layer 1: plots of land (only closed polylignes)
In layer 2: buildings (only closed polylignes)

The DXF files that I use do not include hatching, the distinction between plots land and the buildings is made only by means of a color code (Black polylines for plots land and blue polylines for buildings).

I have to manually draw the hatch in each building.
Currently to do this I use the fonction "hatched areas" and the keyboard shortcut "F3".
It works fine but it takes a long time (several hundred buildings !!!).

I would like to draw hatches in the constructions of layer 2 automatically.
Is it possible to do this using a macro d3m?

The desired operation would be:
Selecting all the buildings in layer 2 and hatch all of this buildings in one operation.
For recall the perimeter of each of the buildings is a closed line and there is nothing else in the layer 2.

It's probably easier said than done, but I would win a lot of time with a macro.

I found this forum a great macro to remove duplicate lines.
When I see what that this macro can do, I think that it may be possible to solve my problem.

Thanks in advance.

I'm not experimented in basiccad but I learn a lot by reading ... and I improve my English.

Goopie

prl

Quote from: GooPie on February 24, 2015, 11:11:15 AM
Is it possible to do this using a macro d3m?

Yes,

Note when the routine is finished, all the lines on layer 2 are now hatches and are selected.  If you don't like the hatching pattern, use the infobox and you can globally change them all to something else of your choosing.

'Program:  l2h.d3m (line to hatches)

'Special routine, cycles database and converts all lines on layer 2 to hatching.

sys(80)=0
tot = sys(9)
for i = 1 to tot
    getattr i, type, select, laynum, groupid, red, green, blue, solidid
   
    if laynum = 2 then
       putattr i, 17, 1
    endif
   
next i

regen   

if sys(80) > 0 then
   precision 0
   count = sys(80)
   
   Message count, "lines converted to hatching"
endif

End


GooPie

Prl thank you,

I need more time to ask my question that you to give me a solution !!!

I just tested the macro: 4264 lines converted in 1 second ... wow !!!
This is great.

The only thing is that my polylines are now clear.
I first said it was annoying, but in a stroke of Genius  ;D (french humor) I thought it was enough to import DXF again.

I'll finick a little, is it possible to do the same thing but keeping polylines?

Thank you again.

JJG

you may have to copy them previously (using Ctrl C for example ... and them paste them, Ctrl V, or with any other way to do that)
;)

GooPie

prl,
I just read the basiccad documentation to understand the macro
Another question:
In the function "putattr i, 17, 1" I do not understand the last character "1"

JJG, CTRL C / CTRL V is a good idea but it should be copied to another layer and then move the copy in layer 2. Without this it is difficult to reposition the lines in the right place. With a few buildings it's easy but my drawing is really big. Another macro can do this?

By importing the DXF file 2 times I also have the problem of having a lot of duplicate lines from layer 1 (plots of land)  :-\

DrollTroll

#5
The '1' selects that entity.

The first argument to PutAttr is the entity id to be modified. The second is the entity type (rarely will you want to change this, as it can be dangerous. In this case prl is graciously assuming everything is a line.).  The third is the selection status (1 selects, 0 de-selects). And so on as described in the docs.
25 years with DesignCAD

GooPie

DrollTroll,
Ok it's clearer to me

It's time to go to sleep for me.
Thank you all.

prl

Quote from: GooPie on February 24, 2015, 12:07:19 PM
  is it possible to do the same thing but keeping polylines?

Bienvenue à BasicCAD!

And please note Dt's warning .  I'm assuming everything on layer two is a polyline.  If you put something else there, text for example, you will find this routine very interesting.

'Program:  l2h.d3m (line to hatches)

'Special routine, cycles database and converts all lines on layer 2 to hatching.

>selectlayer
{
<layer 2
}

'copy the selection set to the clipboard for paste routine
>sethandle
{
<type 0
<pointxyz [0,0,0]
}

>copy
{
}

sys(80)=0
tot = sys(9)
for i = 1 to tot
    getattr i, type, select, laynum, groupid, red, green, blue, solidid
   
    if laynum = 2 then
       putattr i, 17, 1
    endif
   
next i

regen   

if sys(80) > 0 then
   precision 0
   count = sys(80)
   
   Message count, "lines converted to hatching"
endif

>paste
{
<pointxyz [0,0,0]
}


End

GooPie

I just saw that it was easy to copy entity from one layer to another layer via the dialog box options.
I thought adopt this solution before I see your last post.
I have now a perfect macro thanks to you.
I take note of the precautions for use.
And this time... I'm really going to sleep.

I'm glad to see that you speak French very well. ;)

Bonne journée

Bob P

Here's another modification.  It only converts those entities in layer 2 that are selected. 
Extra Credit: If you want to keep your original lines, copy everything first (set a convenient handle), do the conversion, then paste back over the hatching.

'Program:  l2h.d3m (line to hatches)

'Special routine, cycles database and converts all lines on layer 2 to hatching.

sys(80)=0
tot = sys(9)
for i = 1 to tot
    getattr i, type, select, laynum, groupid, red, green, blue, solidid
    if select=0 then goto skip
    if laynum = 2 then
       putattr i, 17, 1
    endif
skip: 
next i

regen   

if sys(80) > 0 then
   precision 0
   count = sys(80)
   
   Message count, "lines converted to hatching"
endif

End

prl

#10
Quote from: Bob P on February 24, 2015, 02:21:19 PM
Here's another modification.  It only converts those entities in layer 2 that are selected. 
Extra Credit: If you want to keep your original lines, copy everything first (set a convenient handle), do the conversion, then paste back over the hatching.

Exactly.  The blue added code above is the same as these stand-alone routines. http://forum.designcad.com/index.php?topic=6118.msg43472#msg43472

GooPie

Hello,

For the pleasure of learning I try to improve the macro.
These are my first steps in basiccad and it's a bit complicated. I am not a computer expert.

The changes are in red.

It works but it is perhaps not very academic.


-----------------------------------------------------------------------------------------------

'Program:  l2h.d3m (line to hatches)

'Special routine, cycles database and converts all lines on semected layer to hatching.

SYS$(41) ="Layer Selection"

INPUT "Layer = ?",laynumber
IF SYS(999) = 1 THEN END

>selectlayer
{
<Layer [laynumber]
}

'copy the selection set to the clipboard for paste routine
>sethandle
{
<type 0
<pointxyz [0,0,0]
}

>copy
{
}

sys(80)=0
tot = sys(9)
for i = 1 to tot
    getattr i, type, select, laynum, groupid, red, green, blue, solidid
   
    if laynum = laynumber then
       putattr i, 17, 1,laynumber

    endif
   
next i

regen   

if sys(80) > 0 then
   precision 0
   count = sys(80)
   
   Message count, "lines converted to hatching"
endif

>paste
{
<pointxyz [0,0,0]
}

End

-----------------------------------------------------------------------------------------------

Thank you for your opinion.

GooPie

prl

Quote from: GooPie on February 25, 2015, 01:05:15 PM
Thank you for your opinion.

Looks fine.  Warning, BasicCAD is addictive!

GooPie

Another question, how do we assign the value 2 to the default layer to be treated?

I try many things but I do not know how.
I stopped at this before you ask for your help:

SYS$(41) ="Layer Selection"

'default value
laynumber = 2
laynumber$ = laynumber

INPUT "Layer (Default=2) = ?",laynumber$
IF SYS(999) = 1 THEN END

if laynumber$ <> ""
Then laynumber = Val(laynumber$)
if (laynumber < 0) or (laynumber > 1000) Then laynumber = 2

This is very bad and more now I have a headache  :(

DrollTroll

While I haven't actually run your code, that looks about right, except that

if laynumber$ <> ""
Then laynumber = Val(laynumber$)

should be on a single line.

Otherwise you're doing well -- you're defining a default value, then validating that the input is something reasonable.
25 years with DesignCAD