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

0 Members and 1 Guest are viewing this topic.

kozmos

  • Newt
  • Posts: 93
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: 8434
  • 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: 1345
  • 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: 93
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: 629
OpenDCL has the "HATCH" control ...

BIGAL

  • Swamp Rat
  • Posts: 1345
  • 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: 629

xdcad

  • Newt
  • Posts: 194
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

xdcad

  • Newt
  • Posts: 194
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.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

xdcad

  • Newt
  • Posts: 194
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.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

domenicomaria

  • Swamp Rat
  • Posts: 629
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

  • Newt
  • Posts: 194
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.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

domenicomaria

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

however you need to write an help file !

xdcad

  • Newt
  • Posts: 194
@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.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

domenicomaria

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



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

? ? ?


xdcad

  • Newt
  • Posts: 194
_$ (type xdrx-setproperty)
EXRXSUBR



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

? ? ?

xd::drag:simplemove is defined in the xd-lisp-lib.vlx file.
If xdrx.lsp exists in the sys directory(or is in the same directory as the xdrx**.arx file), , this file will be automatically loaded.

Can you post a screenshot of the text box after starting AUTOCAD to see if the XD General LISP function library(xd-lisp-lib.vlx) is loaded?

============

After xdrx**.arx is loaded, it will automatically look for the xdrx.lsp file. If it exists, ARX will automatically load xdrx.lsp, and then xdrx.lsp will do subsequent initialization and other work.

Currently, xdrx.lsp will load opendcl, xd-lisp-lib.vlx....

Code: [Select]
Command: !xd::drag:simplemove
#<SUBR @000001d1e7a226d8 XD::DRAG:SIMPLEMOVE>

Command: (type xd::drag:simplemove)
SUBR
« Last Edit: November 18, 2023, 12:54:41 PM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

domenicomaria

  • Swamp Rat
  • Posts: 629
Application Error: 2 :- no function definition: XD::VAR:ISZWCAD

domenicomaria

  • Swamp Rat
  • Posts: 629
What is the best software for making beautiful CHM files nowadays?

I saw that the xdrx_api_manual_2017-1208.html file exists,
but many parts are in Chinese, (we only need English)
and other parts are incomplete...

xdcad

  • Newt
  • Posts: 194
Application Error: 2 :- no function definition: XD::VAR:ISZWCAD

Replace the xdrx.lsp you installed with the file in the attachment.
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

xdcad

  • Newt
  • Posts: 194
What is the best software for making beautiful CHM files nowadays?

I saw that the xdrx_api_manual_2017-1208.html file exists,
but many parts are in Chinese, (we only need English)
and other parts are incomplete...

This is a time-consuming and boring job. I will try to finish it later.
In fact, many functions can be used
xdrx-getpropertyvalue(query)
xdrx-setpropertyvalue(edit)

substitute.

If you only provide the entity name parameter, you will get help.
The picture above is to query whether the block table record object is an overlay.

Command: (setq a (xdrx-entsel "\n Pick a Insert:" '((0 . "insert"))))
  Pick a Insert:(<Character name: 20adf0d7b90> (941.481 1061.93 0.0))


Command: (xdrx-object-isa (car a))
"AcDbBlockReference"


Command: (xdrx-getpropertyvalue (car a))
Class AcDbBlockReference:

     ├─isDynamicBlock(2007+)
     ├─AllEntities
     ├─Entities
     ├─AttDefEntities
     ├─AttributeEntities
     ├─HasAttribute
     ├─BlockReferenceEntities
     ├─BlockTableRecord
     ├─BlockTransform
     ├─Name
     ├─Normal
     ├─Position
     ├─Rotation
     ├─ScaleFactors
     ├─SubEntBox (None or T)
     ├─TextBox (None or T)
     ├─TigerBox (None or T)
     ├─WOFrame
  *** Clip Query Function ***
     ├─isCliped
     ├─ClipIsEnabled
     ├─ClipIsInverted
     ├─ClipFilterObject
     ├─ClipElevation
     ├─FrontClip
     ├─BackClip
     ├─ClipBoundary
     ├─ClipHasPerspectiveCamera
     ├─ClipVolume
     ├─ClipSpaceToWCSMatrix
     ├─ClipVolumeIntersectsExtents
     ├─ClipOriginalInverseBlockXform
     ├─ClipQueryBounds
Class AcDbEntity:
     ├─9PT
     ├─BoundingBox
     ├─........................
Class AcDbObject:
     ├─ClassName
     ├─OriginalDatabase
     ├─Database
     ├─........................

Command: (setq b (xdrx-getpropertyvalue (car a) "blocktablerecord"))
("a" <element name: 20adf0d7b50>)


Command: (xdrx-object-isa (cadr b))
"AcDbBlockTableRecord"


Command: (xdrx-getpropertyvalue (cadr b) "IsFromOverlayReference")
nil


Command: (xdrx-getpropertyvalue (cadr b))
Class AcDbBlockTableRecord:
     ├─AttDefEntites
     ├─AllEntities
     ├─BlockReferenceEntities
     ├─Entities
     ├─ErasedBlockReferenceEntities
     ├─Comments
     ├─WOFrame
     ├─WOFrameType
     ├─WOFrameColor
     ├─WOFrameWidth
     ├─Explodable
     ├─HasAttributeDefinitions
     ├─HasPreviewIcon
     ├─IsAnonymous
     ├─IsFromExternalReference
     ├─IsFromOverlayReference
     ├─IsLayOut
     ├─LayOutName
     ├─IsUnloaded
     ├─LayOutId
     ├─Origin
     ├─PathName
     ├─SortentsTable
     ├─WOFrame
     ├─XrefDatabase
     ├─XrefStatus
Class AcDbSymbolTableRecord:
     ├─Name
Class AcDbObject:
     ├─........................

These methods basically correspond to the methods under the object library in the ARX help manual. You can check the required parameters through arxref.chm. Many query functions do not require parameters, only the entity name variable to be queried.
« Last Edit: November 18, 2023, 02:36:23 PM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

domenicomaria

  • Swamp Rat
  • Posts: 629
Application Error: 2 :- no function definition: XD::VAR:ISZWCAD

Replace the xdrx.lsp you installed with the file in the attachment.

yes, now it works

xdcad

  • Newt
  • Posts: 194
Application Error: 2 :- no function definition: XD::VAR:ISZWCAD

Replace the xdrx.lsp you installed with the file in the attachment.

yes, now it works

xd::drag:simplemove

The function is mainly the parameter 5, the base point of dragging. This parameter represents the entity you want to drag or one of the 9 points of the selection set bounding box. 5 represents the center point, 1 represents the lower left point, and 9 represents the upper right point. ..
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net

xdcad

  • Newt
  • Posts: 194
Application Error: 2 :- no function definition: XD::VAR:ISZWCAD

Replace the xdrx.lsp you installed with the file in the attachment.

yes, now it works

xd::drag:simplemove

The last parameter:

t :  move
nil: copy
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net