Entmake Hatch (with base point or object {Polyline} entity name).

Entmake Hatch (with base point or object {Polyline} entity name).

Muhammed.OPERA
Advisor Advisor
5,256 Views
28 Replies
Message 1 of 29

Entmake Hatch (with base point or object {Polyline} entity name).

Muhammed.OPERA
Advisor
Advisor

Hi everyone,

 

I have been working on a lisp file to draw custom things, then i have faced that nightmare.

Really it's a nightmare, i have searched every web page looking for a way to make hatch with Entmake  not vla not -bhatch, then i have found a code by Mr. Elpanov Evgeniy and Mr. LEE Mac but those codes can't help me with that issue.

I wanna make a hatch with entmake for a polyline (complex polyline with arcs& lines inside) and that would be with either: selecting a point inside (pick point) or selecting the polyline itself (select object by having it's entity name).

I have tried every possible trial i can make with the dxf group codes of hatch and it's boundary but i couldn't accomplish that.

Do you have any ideas?

Is that even possible?! i think it is, as it's pre-programmed in AutoCAD hatch command.

 

Thanks in advance. 


Muhammed Mamdouh (OPERA)
Structural Engineer, Instructor
Facebook |LinkedIn

EESignature

0 Likes
Accepted solutions (1)
5,257 Views
28 Replies
Replies (28)
Message 21 of 29

CodeDing
Advisor
Advisor
(if vanilla
  (continue)
  (exit)
);if
0 Likes
Message 22 of 29

ronjonp
Mentor
Mentor

@CodeDing wrote:

@ronjonp ,

 

Can you benchmark this one? This reflects 2 changes:

 - Mapcar in "CreateHatchList"

 - removed unnecessary mapcar from "entmakex-hatch"...

.......
(mapcar '(lambda (b) b) a)
....... to .......
a
.......

Best,

~DD

 


It got slower with that change:

_$ 

_VLA-ADDHATCH 
CREATEHATCHLIST 
ENTMAKEX-HATCH 
<Entity name: 2cc8f123bc0> 
#<VLA-OBJECT IAcadModelSpace 000002ccaadbda58> Benchmarking ............Elapsed milliseconds / relative speed for 512 iteration(s):

    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1640 / 2.24 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........3671 / 1.00 <slowest>

 
; 6 forms loaded from #<editor "<Untitled-0> loading...">
_$ 
_$ 

 

0 Likes
Message 23 of 29

CodeDing
Advisor
Advisor


It got slower with that change:


 

Weird. ¯\_(ツ)_/¯ Thanks for checking

0 Likes
Message 24 of 29

CodeDing
Advisor
Advisor

@ronjonp ,

 

Are you sure you ran the right one? Thank you for posting your .lsp, I was able to test it also.

Command: _appload benchhatch.lsp successfully loaded.
Command:
Elapsed milliseconds / relative speed for 1024 iteration(s):
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....2828 / 1.02 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........2891 / 1.00 <slowest>
Command:

They're nearly identical in this case.

 

EDIT:

It may appear that the larger the entity, the slower this entmakex becomes. This is results from scaling the same entity by 50:

Command: _appload benchhatch.lsp successfully loaded.
Command:
Elapsed milliseconds / relative speed for 1024 iteration(s):
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1485 / 2.09 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........3109 / 1.00 <slowest>
Command:

 

Best,

~DD

 

0 Likes
Message 25 of 29

ronjonp
Mentor
Mentor

I did test your other code but posted the one that ran fastest for me. Strange .. just ran the code you just posted and it is a much different result than what you see?

_$ 

_VLA-ADDHATCH 
ENTMAKEX-HATCH Benchmarking .............Elapsed milliseconds / relative speed for 1024 iteration(s):

    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1828 / 3.15 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........5766 / 1.00 <slowest>

T 
_$ 
_$ 
0 Likes
Message 26 of 29

CodeDing
Advisor
Advisor

After doing everything within my known power to 'trim the fat' from this lisp, it gets close, but still not better. This is the best I can get:

Elapsed milliseconds / relative speed for 1024 iteration(s):
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1688 / 1.20 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........2031 / 1.00 <slowest>
..............................
Elapsed milliseconds / relative speed for 1024 iteration(s):
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1672 / 1.11 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........1859 / 1.00 <slowest>
..............................
Elapsed milliseconds / relative speed for 1024 iteration(s):
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1688 / 1.12 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........1891 / 1.00 <slowest>

...since the visual lisp method only hatches one entity, I modified the entmakex portion to also only accept one entity. Then rearranged some stuff, removed some stuff, and that's your result. I have attached the lisp. Also, it is worth noting that I am now under the assumption that, in this case, the foreach statement will run faster than mapcar/lambda.

 

EDIT /// HOLD THE PHONES..!..!..!..

Check out what happens when I switch these two...

     (benchmark	'((_vla-addhatch sp (vlax-ename->vla-object e) "ANSI31" 0.0 1.0)
                  (entmakex-hatch e 0.0 "ANSI31" 1.0)		  
		 )
......... to ..........
     (benchmark	'((entmakex-hatch e 0.0 "ANSI31" 1.0)
		  (_vla-addhatch sp (vlax-ename->vla-object e) "ANSI31" 0.0 1.0)
		 )
Elapsed milliseconds / relative speed for 2048 iteration(s):
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........3687 / 1.26 <fastest>
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....4641 / 1.00 <slowest>
.................
Elapsed milliseconds / relative speed for 2048 iteration(s):
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........3735 / 1.24 <fastest>
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....4641 / 1.00 <slowest>
.................
Elapsed milliseconds / relative speed for 2048 iteration(s):
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........3719 / 1.26 <fastest>
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....4703 / 1.00 <slowest>

... IT'S A CONSPIRACY! Lol, now we gotta delete this benchmark. ¯\_(ツ)_/¯

 

Best,

~DD

0 Likes
Message 27 of 29

ronjonp
Mentor
Mentor

@CodeDing  That is very strange .. my results after swapping the tests.

_$ 

_VLA-ADDHATCH 
ENTMAKEX-HATCH Benchmarking ............Elapsed milliseconds / relative speed for 512 iteration(s):

    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........1047 / 1.49 <fastest>
    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1562 / 1.00 <slowest>

T 
; 3 forms loaded from #<editor "<Untitled-0> loading...">
_$ 
0 Likes
Message 28 of 29

john.uhden
Mentor
Mentor
I guess my guesstimate of around a 5 millisecond difference was in the ball
park.
It's fitting today that I am doing quantity take-offs for a residential
development project...
"looks like about 10,000 feet of curb to me"

<>
Virus-free.
www.avg.com
<>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

John F. Uhden

0 Likes
Message 29 of 29

ronjonp
Mentor
Mentor

@CodeDing  That last version you posted and benchmarked, the entmake does not create the hatch for me?

Here are the results of the test swapping the order and testing back to back with the last version of the code that worked for me.

_$ 

_VLA-ADDHATCH 
ENTMAKEX-HATCH Benchmarking ............Elapsed milliseconds / relative speed for 512 iteration(s):

    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1578 / 1.84 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........2906 / 1.00 <slowest>
Benchmarking ............Elapsed milliseconds / relative speed for 512 iteration(s):

    (_VLA-ADDHATCH SP (vlax-ename->vla-o...).....1719 / 2.33 <fastest>
    (ENTMAKEX-HATCH E 0.0 "ANSI31" 1.0)..........4000 / 1.00 <slowest>

T 
; 3 forms loaded from #<editor "C:/Users/rperez/Desktop/benchhatch.lsp">
_$ 
0 Likes