Author Topic: Is there a way to convery hatch into lines without using explode command?  (Read 2920 times)

0 Members and 2 Guests are viewing this topic.

kozmos

  • Newt
  • Posts: 119
I'd like to know if there is a way to get the lines of a hatch without calling explode command to explode it.
KozMos Inc.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8927
  • AKA Daniel
I didn’t see anything in lisp,  ARX has AcDbHatch::getHatchLinesData

Code - Python: [Select]
  1. def PyRxCmd_doit():
  2.     try:
  3.         picktype = Db.Hatch.desc()
  4.         es = Ed.Editor.entSel("\nPick it",picktype)
  5.         if es[0] != Ed.PromptStatus.eNormal:
  6.             return
  7.        
  8.         hatch = Db.Hatch(es[1])
  9.         data = hatch.getHatchLinesData()
  10.         for s, e in zip(data[0],data[1]):
  11.             Ed.Core.grDraw(
  12.                 Ge.Point3d(s[0],s[1],0),
  13.                 Ge.Point3d(e[0],e[1],0),1,0)
  14.            
  15.     except Exception as err:
  16.         traceback.print_exception(err)
  17.  

BIGAL

  • Swamp Rat
  • Posts: 1474
  • 40 + years of using Autocad
Another is copy hatch a set distance say to right, get bounding box of hatch, explode hatch, can use ssget CP using bounding box to get lines, can apply an offset X to the ends of lines to be true values compared to original hatch.

You did not say what your doing with the lines.
A man who never made a mistake never made anything

kozmos

  • Newt
  • Posts: 119
Another is copy hatch a set distance say to right, get bounding box of hatch, explode hatch, can use ssget CP using bounding box to get lines, can apply an offset X to the ends of lines to be true values compared to original hatch.

You did not say what your doing with the lines.

I attempt to display the hatchlines in DCL for preview the hatch object, that is why I am trying to avoid using explode command.
KozMos Inc.

domenicomaria

  • Swamp Rat
  • Posts: 743
OpenDCL has the "HATCH" control ...

BIGAL

  • Swamp Rat
  • Posts: 1474
  • 40 + years of using Autocad
You can have predefined images in a dcl. I have like 2x2 3x3 4x4 etc. The images are slides. Yes you can do vectors in a dcl image but slides are so much easier to use.



A man who never made a mistake never made anything

domenicomaria

  • Swamp Rat
  • Posts: 743

xdcad

  • Swamp Rat
  • Posts: 527
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

xdcad

  • Swamp Rat
  • Posts: 527
maybe  XDRX-HATCH->LINES ?

https://github.com/xdcad/XDrx-API

Command: (setq a (xdrx-hatch->lines (car (xdrx-entsel "\nPick a Hatch:" '((0 . "hatch"))))))
Pick a Hatch:((((11327.1 -1683.7 0.0) (11345.2 -1665.52 0.0)) ((11327.1 -1966.54 0.0) (11628.1 -1665.52 0.0)) ((11327.1 -2249.39 0.0) (11910.9 -1665.52 0.0)) ((11562.7 -2296.55 0.0) (12193.8 -1665.52 0.0)) ((11845.6 -2296.55 0.0) (12476.6 -1665.52 0.0)) ((12128.4 -2296.55 0.0) (12614.5 -1810.51 0.0)) ((12411.3 -2296.55 0.0) (12614.5 -2093.36 0.0)) ((11327.1 -1693.7 0.0) (11355.2 -1665.52 0.0)) ((11327.1 -1976.54 0.0) (11638.1 -1665.52 0.0)) ((11327.1 -2259.39 0.0) (11920.9 -1665.52 0.0)) ((11572.7 -2296.55 0.0) (12203.8 -1665.52 0.0)) ((11855.6 -2296.55 0.0) (12486.6 -1665.52 0.0)) ((12138.4 -2296.55 0.0) (12614.5 -1820.51 0.0)) ((12421.3 -2296.55 0.0) (12614.5 -2103.36 0.0))))
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

xdcad

  • Swamp Rat
  • Posts: 527
maybe  XDRX-HATCH->LINES ?

https://github.com/xdcad/XDrx-API

Another universal function:

Command: (xdrx-getpropertyvalue (car (entsel)) "hatchlines")
Select objects: (((11327.1 -1683.7 0.0) (11345.2 -1665.52 0.0)) ((11327.1 -1966.54 0.0) (11628.1 -1665.52 0.0)) ((11327.1 -2249.39 0.0) (11910.9 -1665.52 0.0)) ((11562.7 - 2296.55 0.0) (12193.8 -1665.52 0.0)) ((11845.6 -2296.55 0.0) (12476.6 -1665.52 0.0)) ((12128.4 -2296.55 0.0) (12614.5 -1810.51 0.0) ) ((12411.3 -2296.55 0.0) (12614.5 -2093.36 0.0 )) ((11327.1 -1693.7 0.0) (11355.2 -1665.52 0.0)) ((11327.1 -1976.54 0.0) (11638.1 -1665.52 0.0)) ((11327.1 -2259.39 0.0) (11920.9 -16 65.52 0.0)) ((11572.7 -2296.55 0.0 ) (12203.8 -1665.52 0.0)) ((11855.6 -2296.55 0.0) (12486.6 -1665.52 0.0)) ((12138.4 -2296.55 0.0) (12614.5 -1820.51 0.0)) ((12421.3 -2 296.55 0.0) (12614.5 -2103.36 0.0)) )
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

domenicomaria

  • Swamp Rat
  • Posts: 743
Code - Auto/Visual Lisp: [Select]
  1. (defun :ENTLAST ( / ent-last ent-next )
  2.    (if(setq ent-last (entlast) )
  3.       (while (setq ent-next (entnext ent-last) )   (setq ent-last ent-next) )
  4.      )
  5.      ent-last
  6. )
  7.  
  8. (defun :SS-CATCH (x-en / tmp ss)
  9.    (setq ss (ssadd))
  10.    (while (setq x-en (if x-en (entnext x-en)   (entnext) ) ) (ssadd x-en ss) )
  11.    (if (> (sslength ss) 0) ss nil)
  12. )
  13.  
  14. (defun :LINE (p1 p2)
  15.    (entmakex
  16.       (list   '(0 . "LINE") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbLine") (cons 10 p1) (cons 11 p2) )
  17.    )
  18. )
  19.  
  20. (defun C:HATCH2LINES ( / el es line-group-lst ssa )
  21.    (setq el (:ENTLAST) )
  22.    (setvar "cecolor" "222")
  23.    (setq es (car (entsel "\nselect hatch : ")))
  24.    (setq line-group-lst (XDRX-HATCH->LINES es))
  25.    (foreach line-group line-group-lst
  26.       (foreach line line-group (:LINE (car line) (cadr line) ) )
  27.    )
  28.    (setq ssa (:SS-CATCH el) )
  29.    (command "move" ssa "")
  30. )
  31.      
  32.  
  33. (defun C:H2L () (C:HATCH2LINES) )

Yes ... it works ...

xdcad

  • Swamp Rat
  • Posts: 527
Code - Auto/Visual Lisp: [Select]
  1. (defun :ENTLAST ( / ent-last ent-next )
  2.    (if(setq ent-last (entlast) )
  3.       (while (setq ent-next (entnext ent-last) )   (setq ent-last ent-next) )
  4.      )
  5.      ent-last
  6. )
  7.  
  8. (defun :SS-CATCH (x-en / tmp ss)
  9.    (setq ss (ssadd))
  10.    (while (setq x-en (if x-en (entnext x-en)   (entnext) ) ) (ssadd x-en ss) )
  11.    (if (> (sslength ss) 0) ss nil)
  12. )
  13.  
  14. (defun :LINE (p1 p2)
  15.    (entmakex
  16.       (list   '(0 . "LINE") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbLine") (cons 10 p1) (cons 11 p2) )
  17.    )
  18. )
  19.  
  20. (defun C:HATCH2LINES ( / el es line-group-lst ssa )
  21.    (setq el (:ENTLAST) )
  22.    (setvar "cecolor" "222")
  23.    (setq es (car (entsel "\nselect hatch : ")))
  24.    (setq line-group-lst (XDRX-HATCH->LINES es))
  25.    (foreach line-group line-group-lst
  26.       (foreach line line-group (:LINE (car line) (cadr line) ) )
  27.    )
  28.    (setq ssa (:SS-CATCH el) )
  29.    (command "move" ssa "")
  30. )
  31.      
  32.  
  33. (defun C:H2L () (C:HATCH2LINES) )

Yes ... it works ...


The following is support for selection sets:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:h2l ()
  2.   (if (setq ss (xdrx-ssget
  3.                  "\nSelect Hatch Entities<Quit>:"
  4.                  '((0 . "hatch"))
  5.                )
  6.       )
  7.     (progn
  8.       (xdrx-begin)
  9.       (setq ss (mapcar '(lambda(x)(xdrx-hatch->lines x))(xdrx-pickset->ents ss)))
  10.       (xdrx-setmark)
  11.       (mapcar '(lambda (x)
  12.                  (mapcar '(lambda(y)
  13.                             (foreach n y (xdrx-line-make n))) x)
  14.                )
  15.               ss
  16.       )
  17.       (setq ss (xdrx-getss))
  18.       (xdrx-setproperty ss "color" 222)
  19.       (xd::drag:simplemove ss "\nInsert Point:" 5 t);1. Parameter 5, select the center point of the set bounding box to move the insertion point, 2. Parameter T move, NIL copy
  20.       (xdrx-end)
  21.     )
  22.   )
  23.   (princ)
  24. )

The above LISP code uses the XDRX-API, which can be downloaded from https://github.com/xdcad/XDrx-API

The XDRX API encapsulates AcDb, AcEd, AcGe, AcBr... C++ library, using C++ methods to develop LISP programs.Thousands of Lisp functions are available.
« Last Edit: November 17, 2023, 03:39:20 PM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

domenicomaria

  • Swamp Rat
  • Posts: 743
@xdcad
... every thing ... very interesting !

however you need to write an help file !

xdcad

  • Swamp Rat
  • Posts: 527
@xdcad
... every thing ... very interesting !

however you need to write an help file !


What is the best software for making beautiful CHM files nowadays?
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

domenicomaria

  • Swamp Rat
  • Posts: 743
_$ (type xdrx-setproperty)
EXRXSUBR



_$ (type xd::drag:simplemove)
nil

? ? ?