Author Topic: ENTMAKE function  (Read 38622 times)

0 Members and 1 Guest are viewing this topic.

Didge

  • Bull Frog
  • Posts: 211
Re: ENTMAKE function
« Reply #45 on: May 31, 2006, 06:20:27 AM »
An extremely useful routine, thanks CAB & all those that contributed.

I've noticed that 'eMaking' into another drawing however ignores objects originally drawn using linetypes and text styles that arent loaded in the new drawing. I've added a few more exceptions (see code) as a temporary fix.

If I ever get the time I may try including commands to re-define the text styles and load the relevant linetypes into a new drawing prior to processing all the entmakes.


Code: [Select]
(defun dxfstrip (ent / entl dxfx)
(setq entl (entget ent)
dxfx '(-2 -1 5 102 300 330 331 340 350 360 410)
;; additional codes to strip
dxfx (cond ((= (cdr (assoc 0 entl)) "DIMENSION")
(append dxfx '(2 210))
)
((= (cdr (assoc 0 entl)) "HATCH")
(append dxfx '(67))
)
((= (cdr (assoc 0 entl)) "INSERT")
(append dxfx '(40 41 42 43 44 45 50 71 210))
)
((= (cdr (assoc 0 entl)) "TEXT") ; remove text style, added by didge.
(append dxfx '(7))
)
((= (cdr (assoc 0 entl)) "LINE") ; remove linetype, added by didge.
(append dxfx '(6))
)
((= (cdr (assoc 0 entl)) "LWPOLYLINE") ; remove linetype, added by didge.
(append dxfx '(6))
)
(t (append dxfx '(210)))
)
entl (vl-remove-if '(lambda (pair) (member (car pair) dxfx)) entL)
)
;; CORRECTIONS FOR SPECIAL OBJECTS
(cond
;; Make Hatch Non-associative
((= (cdr (assoc 0 entl)) "HATCH")
(setq entl (replace '(71 . 0) '(71 . 1) entl))
(setq entl (replace '(97 . 0) (assoc 97 entl) entl))
(prompt "\n*** Warning Hatch created is Non-associative ***")
)
((= (cdr (assoc 0 entl)) "LEADER")
(prompt "\n*** Warning Leader created is Non-associative ***")
)
)
;; filter out objects that can not be created at this time
entl
) ; defun
Think Slow......

CAB

  • Global Moderator
  • Seagull
  • Posts: 10366
Re: ENTMAKE function
« Reply #46 on: May 31, 2006, 08:09:27 AM »
An extremely useful routine, thanks CAB & all those that contributed.

I've noticed that 'eMaking' into another drawing however ignores objects originally drawn using linetypes and text styles that arent loaded in the new drawing. I've added a few more exceptions (see code) as a temporary fix.

If I ever get the time I may try including commands to re-define the text styles and load the relevant linetypes into a new drawing prior to processing all the entmakes.

Thanks Didge.

Is it necessary to you to remove them? Don't they just convert to the "Current" value in the drawing?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Didge

  • Bull Frog
  • Posts: 211
Re: ENTMAKE function
« Reply #47 on: May 31, 2006, 08:18:50 AM »
Quote
Don't they just convert to the "Current" value in the drawing?

No it seems like those particular entmakes are skipped, Current color values are used & Acad creates layers accordingly but it doesnt seem to  load linetypes, even standard acad linetypes.

Its not a big problem, just another one of Acad's curios.
Think Slow......

Didge

  • Bull Frog
  • Posts: 211
Re: ENTMAKE function
« Reply #48 on: May 31, 2006, 08:40:58 AM »
I spoke too soon, it looks like the issue may be with properties by entity because properties assigned <by layer> seem to work fine.  Here's a small dwg to demonstrate.



Think Slow......

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1540
  • Moscow (Russia)
Re: ENTMAKE function
« Reply #49 on: April 03, 2007, 06:45:45 AM »
I am surprised!
Unless still nobody wrote creation HATCH?

It is a simple variant, creations not associative hatch for contours from linear segments...
Contour are set by the list of points.

Code: [Select]
(defun entmakex-hatch (L)
 ;; By ElpanovEvgeniy
 ;; 03.04.2007 10:03:51:
 (entmakex
  (apply
   'append
   (list
    (list '(0 . "HATCH")
          '(100 . "AcDbEntity")
          '(410 . "Model")
          '(100 . "AcDbHatch")
          '(10 0.0 0.0 0.0)
          '(210 0.0 0.0 1.0)
          '(2 . "SOLID")
          '(70 . 1)
          '(71 . 0)
          (cons 91 (length l))
    ) ;_  list
    (apply 'append
    (mapcar '(lambda (a)
             (apply 'append
                    (list (list '(92 . 7) '(72 . 0) '(73 . 1) (cons 93 (length a)))
                          (mapcar '(lambda (b) (cons 10 b)) a)
                          '((97 . 0))
                    ) ;_  list
             ) ;_  apply
            ) ;_  lambda
            l
    ) ;_  mapcar
           )
    '((75 . 0)
      (76 . 1)
      (47 . 1.)
      (98 . 2)
      (10 0. 0. 0.0)
      (10 0. 0. 0.0)
      (451 . 0)
      (460 . 0.0)
      (461 . 0.0)
      (452 . 1)
      (462 . 1.0)
      (453 . 2)
      (463 . 0.0)
      (463 . 1.0)
      (470 . "LINEAR")
     )
   ) ;_  list
  ) ;_  apply
 ) ;_  entmakex
)

test:
Code: [Select]
(setq h (entmakex-hatch
         '(((538.794 584.563) (895.629 584.563) (895.629 997.377) (538.794 997.377))
           ((386.809 345.13) (670.955 345.13) (670.955 855.369) (386.809 855.369))
          )
        ) ;_  entmakex-hatch
) ;_  setq
蝸牛そろそろ登れ富士の山 /Kobayashi Issa/

GDF

  • Water Moccasin
  • Posts: 1992
Re: ENTMAKE function
« Reply #50 on: April 03, 2007, 03:59:23 PM »
Here is an update. :)
Fixed bug   8-)


Alan

Wow, I just looked into this thread. This could REALLY come in handy.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10366
Re: ENTMAKE function
« Reply #51 on: April 03, 2007, 08:01:55 PM »
Glad you found it Gary. :-)

Quite a gold mine around here, just happy I could contribute  a few nuggets.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10366
Re: ENTMAKE function
« Reply #52 on: April 04, 2007, 09:01:31 AM »
Evgeniy,
My routine will make a hatch. It does not support Associative hatches and therefore converts them to non associative.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 1992
Re: ENTMAKE function
« Reply #53 on: April 04, 2007, 09:46:28 AM »
Evgeniy,
My routine will make a hatch. It does not support Associative hatches and therefore converts them to non associative.


Alan

The only thing I would suggest you add is support for layer color and linetype.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10366
Re: ENTMAKE function
« Reply #54 on: April 04, 2007, 10:34:18 AM »
Gary,
The routine keeps the existing info in tact, layer color & linetype.
If the drawing where you emtmake the new object is missing the layer and or line type then it uses the current.

Is that what you are referring to?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 1992
Re: ENTMAKE function
« Reply #55 on: April 04, 2007, 10:51:44 AM »
Gary,
The routine keeps the existing info in tact, layer color & linetype.
If the drawing where you emtmake the new object is missing the layer and or line type then it uses the current.

Is that what you are referring to?

Alan

I got to the party late, so I know I am missing some of good stuff...

I just did a simple test, see enclosed drawing. It did not pickup the color and linetype.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10366
Re: ENTMAKE function
« Reply #56 on: April 04, 2007, 11:23:41 AM »
The three lines are "ByLayer" for color & line type. That information was the same for the entmake code.
Therefore the new objects created will rely on the Layer for those settings.
If the lines had an override on the color & line type it would have picked that up.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 1992
Re: ENTMAKE function
« Reply #57 on: April 04, 2007, 12:02:45 PM »
The three lines are "ByLayer" for color & line type. That information was the same for the entmake code.
Therefore the new objects created will rely on the Layer for those settings.
If the lines had an override on the color & line type it would have picked that up.



Thanks. I see that now.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1540
  • Moscow (Russia)
Re: ENTMAKE function
« Reply #58 on: April 05, 2007, 04:59:15 AM »
Evgeniy,
My routine will make a hatch. It does not support Associative hatches and therefore converts them to non associative.


Probably, I have not understood your code...
I very much apologize!
Set an example, as it is possible to create hatch, having the list of points.
蝸牛そろそろ登れ富士の山 /Kobayashi Issa/

CAB

  • Global Moderator
  • Seagull
  • Posts: 10366
Re: ENTMAKE function
« Reply #59 on: April 05, 2007, 08:41:49 AM »
No apology necessary.

My code allows the user to select objects (ssget) and then generates a lisp file with the code needed to
recreate those objects. This is done by stripping the unwanted dxf codes from the entlist before writing
the list to the lisp file. The lisp file is named <dwg name>.lsp

Selecting a single hatch, the out put file would contain this:

Code: [Select]
;; Revision :04/04/2007 @09:45
(defun c:eMake ()
  (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "WorkingLayer") (100 . "AcDbHatch")
  (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "ANSI31") (70 . 0) (71 . 0) (91 . 1) (92 . 7)
  (72 . 1) (73 . 1) (93 . 6) (10 3840.362947224578 -895.4843925631022 0.0)
  (42 . 0.414213562373095) (10 3722.341824578577 -777.4632699171016 0.0)
  (42 . 0.0) (10 3359.224080572738 -777.4632699171018 0.0) (42 . 0.0)
  (10 3359.224080572738 -1281.385497073226 0.0) (42 . 0.0)
  (10 3722.341824578577 -1281.385497073226 0.0) (42 . 0.414213562373095)
  (10 3840.362947224577 -1163.364374427225 0.0) (42 . 0.0) (97 . 0) (75 . 0)
  (76 . 1) (52 . 0.0) (41 . 100.0) (77 . 0) (78 . 1) (53 . 0.785398163397448)
  (43 . 0.0) (44 . 0.0) (45 . -8.838834764831842) (46 . 8.838834764831844)
  (79 . 0) (47 . 1.702439943416909) (98 . 1) (10 3515.061971355171 -947.7072603540719 0.0)))
  (princ)
) ; end eMaker
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.