surface.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  1. # Created: 20.03.2018
  2. # Copyright (c) 2018, Manfred Moitzi
  3. # License: MIT License
  4. from typing import TYPE_CHECKING, Iterable
  5. from ezdxf.lldxf.const import DXFStructureError
  6. from .graphics import none_subclass, entity_subclass, DXFAttr, DXFAttributes, DefSubclass, ExtendedTags, XType
  7. from .solid3d import Body, modeler_geometry_subclass
  8. from . import matrix_accessors
  9. if TYPE_CHECKING:
  10. from ezdxf.eztypes import Matrix44
  11. _SURFACE_TPL = """0
  12. SURFACE
  13. 5
  14. 0
  15. 330
  16. 0
  17. 100
  18. AcDbEntity
  19. 8
  20. 0
  21. 100
  22. AcDbModelerGeometry
  23. 70
  24. 1
  25. 100
  26. AcDbSurface
  27. 71
  28. 0
  29. 72
  30. 0
  31. """
  32. _SURFACE_CLS = """0
  33. CLASS
  34. 1
  35. SURFACE
  36. 2
  37. AcDbSurface
  38. 3
  39. ObjectDBX Classes
  40. 90
  41. 4095
  42. 91
  43. 0
  44. 280
  45. 0
  46. 281
  47. 1
  48. """
  49. surface_subclass = DefSubclass('AcDbSurface', {
  50. 'u_count': DXFAttr(71),
  51. 'v_count': DXFAttr(72),
  52. })
  53. class Surface(Body):
  54. __slots__ = ()
  55. TEMPLATE = ExtendedTags.from_text(_SURFACE_TPL)
  56. CLASS = ExtendedTags.from_text(_SURFACE_CLS)
  57. DXFATTRIBS = DXFAttributes(
  58. none_subclass,
  59. entity_subclass,
  60. modeler_geometry_subclass,
  61. surface_subclass,
  62. )
  63. def _get_matrix(self, code: int) -> 'Matrix44':
  64. subclass = self.tags.subclasses[4] # always 5th subclass, Surface has no transform matrix, but inherited classes
  65. try:
  66. return matrix_accessors.get_matrix(subclass, code)
  67. except DXFStructureError:
  68. raise DXFStructureError('Invalid transformation matrix in entity ' + self.__str__())
  69. def _set_matrix(self, code: int, data: Iterable[float]):
  70. subclass = self.tags.subclasses[4] # always 5th subclass, Surface has no transform matrix, but inherited classes
  71. matrix_accessors.set_matrix(subclass, code, list(data))
  72. _EXTRUDEDSURFACE_TPL = """0
  73. EXTRUDEDSURFACE
  74. 5
  75. 0
  76. 330
  77. 0
  78. 100
  79. AcDbEntity
  80. 8
  81. 0
  82. 100
  83. AcDbModelerGeometry
  84. 70
  85. 1
  86. 100
  87. AcDbSurface
  88. 71
  89. 0
  90. 72
  91. 0
  92. 100
  93. AcDbExtrudedSurface
  94. 90
  95. 18
  96. 10
  97. 0.0
  98. 20
  99. 0.0
  100. 30
  101. 0.0
  102. 40
  103. 1.0
  104. 40
  105. 0.0
  106. 40
  107. 0.0
  108. 40
  109. 0.0
  110. 40
  111. 0.0
  112. 40
  113. 1.0
  114. 40
  115. 0.0
  116. 40
  117. 0.0
  118. 40
  119. 0.0
  120. 40
  121. 0.0
  122. 40
  123. 1.0
  124. 40
  125. 0.0
  126. 40
  127. 0.0
  128. 40
  129. 0.0
  130. 40
  131. 0.0
  132. 40
  133. 1.0
  134. 42
  135. 0.0
  136. 43
  137. 0.0
  138. 44
  139. 0.0
  140. 45
  141. 0.0
  142. 48
  143. 1.0
  144. 49
  145. 0.0
  146. 46
  147. 1.0
  148. 46
  149. 0.0
  150. 46
  151. 0.0
  152. 46
  153. 0.0
  154. 46
  155. 0.0
  156. 46
  157. 1.0
  158. 46
  159. 0.0
  160. 46
  161. 0.0
  162. 46
  163. 0.0
  164. 46
  165. 0.0
  166. 46
  167. 1.0
  168. 46
  169. 0.0
  170. 46
  171. 0.0
  172. 46
  173. 0.0
  174. 46
  175. 0.0
  176. 46
  177. 1.0
  178. 47
  179. 1.0
  180. 47
  181. 0.0
  182. 47
  183. 0.0
  184. 47
  185. 0.0
  186. 47
  187. 0.0
  188. 47
  189. 1.0
  190. 47
  191. 0.0
  192. 47
  193. 0.0
  194. 47
  195. 0.0
  196. 47
  197. 0.0
  198. 47
  199. 1.0
  200. 47
  201. 0.0
  202. 47
  203. 0.0
  204. 47
  205. 0.0
  206. 47
  207. 0.0
  208. 47
  209. 1.0
  210. 290
  211. 0
  212. 70
  213. 0
  214. 71
  215. 2
  216. 292
  217. 1
  218. 293
  219. 0
  220. 294
  221. 0
  222. 295
  223. 1
  224. 296
  225. 0
  226. 11
  227. 0.0
  228. 21
  229. 0.0
  230. 31
  231. 0.0
  232. """
  233. _EXTRUDEDSURFACE_CLS = """0
  234. CLASS
  235. 1
  236. EXTRUDEDSURFACE
  237. 2
  238. AcDbExtrudedSurface
  239. 3
  240. ObjectDBX Classes
  241. 90
  242. 0
  243. 91
  244. 0
  245. 280
  246. 0
  247. 281
  248. 1
  249. """
  250. _ACDBASSOCEXTRUDEDSURFACEACTIONBODY_CLS = """0
  251. CLASS
  252. 1
  253. ACDBASSOCEXTRUDEDSURFACEACTIONBODY
  254. 2
  255. AcDbAssocExtrudedSurfaceActionBody
  256. 3
  257. ObjectDBX Classes
  258. 90
  259. 1025
  260. 91
  261. 0
  262. 280
  263. 0
  264. 281
  265. 0
  266. """
  267. extruded_surface_subclass = DefSubclass('AcDbExtrudedSurface', {
  268. 'class_id': DXFAttr(90),
  269. 'sweep_vector': DXFAttr(10, xtype=XType.point3d),
  270. # 16x group code 40: Transform matrix of extruded entity (16 floats; row major format; default = identity matrix)
  271. 'draft_angle': DXFAttr(42, default=0.), # in radians
  272. 'draft_start_distance': DXFAttr(43, default=0.),
  273. 'draft_end_distance': DXFAttr(44, default=0.),
  274. 'twist_angle': DXFAttr(45, default=0.), # in radians?
  275. 'scale_factor': DXFAttr(48, default=0.),
  276. 'align_angle': DXFAttr(49, default=0.), # in radians
  277. # 16x group code 46: Transform matrix of sweep entity (16 floats; row major format; default = identity matrix)
  278. # 16x group code 47: Transform matrix of path entity (16 floats; row major format; default = identity matrix)
  279. 'solid': DXFAttr(290, default=0), # true/false
  280. 'sweep_alignment_flags': DXFAttr(290, default=0), # 0=No alignment; 1=Align sweep entity to path
  281. # 2=Translate sweep entity to path; 3=Translate path to sweep entity
  282. 'align_start': DXFAttr(292, default=0), # true/false
  283. 'bank': DXFAttr(293, default=0), # true/false
  284. 'base_point_set': DXFAttr(294, default=0), # true/false
  285. 'sweep_entity_transform_computed': DXFAttr(295, default=0), # true/false
  286. 'path_entity_transform_computed': DXFAttr(296, default=0), # true/false
  287. 'reference_vector_for_controlling_twist': DXFAttr(11, xtype=XType.point3d),
  288. })
  289. class ExtrudedSurface(Surface):
  290. __slots__ = ()
  291. TEMPLATE = ExtendedTags.from_text(_EXTRUDEDSURFACE_TPL)
  292. CLASS = (
  293. ExtendedTags.from_text(_EXTRUDEDSURFACE_CLS),
  294. ExtendedTags.from_text(_ACDBASSOCEXTRUDEDSURFACEACTIONBODY_CLS),
  295. )
  296. DXFATTRIBS = DXFAttributes(
  297. none_subclass,
  298. entity_subclass,
  299. modeler_geometry_subclass,
  300. surface_subclass,
  301. extruded_surface_subclass,
  302. )
  303. def set_transformation_matrix_extruded_entity(self, matrix: 'Matrix44') -> None:
  304. self._set_matrix(code=40, data=matrix)
  305. def get_transformation_matrix_extruded_entity(self) -> 'Matrix44':
  306. return self._get_matrix(code=40)
  307. def set_sweep_entity_transformation_matrix(self, matrix: 'Matrix44') -> None:
  308. self._set_matrix(code=46, data=matrix)
  309. def get_sweep_entity_transformation_matrix(self) -> 'Matrix44':
  310. return self._get_matrix(code=46)
  311. def set_path_entity_transformation_matrix(self, matrix: 'Matrix44') -> None:
  312. self._set_matrix(code=47, data=matrix)
  313. def get_path_entity_transformation_matrix(self) -> 'Matrix44':
  314. return self._get_matrix(code=47)
  315. _LOFTEDSURFACE_TPL = """0
  316. LOFTEDSURFACE
  317. 5
  318. 0
  319. 330
  320. 0
  321. 100
  322. AcDbEntity
  323. 8
  324. 0
  325. 100
  326. AcDbModelerGeometry
  327. 70
  328. 1
  329. 100
  330. AcDbSurface
  331. 71
  332. 0
  333. 72
  334. 0
  335. 100
  336. AcDbLoftedSurface
  337. 40
  338. 1.0
  339. 40
  340. 0.0
  341. 40
  342. 0.0
  343. 40
  344. 0.0
  345. 40
  346. 0.0
  347. 40
  348. 1.0
  349. 40
  350. 0.0
  351. 40
  352. 0.0
  353. 40
  354. 0.0
  355. 40
  356. 0.0
  357. 40
  358. 1.0
  359. 40
  360. 0.0
  361. 40
  362. 0.0
  363. 40
  364. 0.0
  365. 40
  366. 0.0
  367. 40
  368. 1.0
  369. 70
  370. 0
  371. 41
  372. 0.0
  373. 42
  374. 0.0
  375. 43
  376. 0.0
  377. 44
  378. 0.0
  379. 290
  380. 0
  381. 291
  382. 1
  383. 292
  384. 1
  385. 293
  386. 1
  387. 294
  388. 0
  389. 295
  390. 0
  391. 296
  392. 0
  393. 297
  394. 1
  395. """
  396. _LOFTEDSURFACE_CLS = """0
  397. CLASS
  398. 1
  399. LOFTEDSURFACE
  400. 2
  401. AcDbLoftedSurface
  402. 3
  403. ObjectDBX Classes
  404. 90
  405. 0
  406. 91
  407. 0
  408. 280
  409. 0
  410. 281
  411. 1
  412. """
  413. _ACDBASSOCLOFTEDSURFACEACTIONBODY_CLS = """0
  414. CLASS
  415. 1
  416. ACDBASSOCLOFTEDSURFACEACTIONBODY
  417. 2
  418. AcDbAssocLoftedSurfaceActionBody
  419. 3
  420. ObjectDBX Classes
  421. 90
  422. 1025
  423. 91
  424. 0
  425. 280
  426. 0
  427. 281
  428. 0
  429. """
  430. lofted_surface_subclass = DefSubclass('AcDbLoftedSurface', {
  431. # 16x group code 40: Transform matrix of loft entity (16 floats; row major format; default = identity matrix)
  432. 'plane_normal_lofting_type': DXFAttr(70),
  433. 'start_draft_angle': DXFAttr(41, default=0.), # in radians
  434. 'end_draft_angle': DXFAttr(42, default=0.), # in radians
  435. 'start_draft_magnitude': DXFAttr(43, default=0.),
  436. 'end_draft_magnitude': DXFAttr(44, default=0.),
  437. 'arc_length_parameterization': DXFAttr(290, default=0), # true/false
  438. 'no_twist': DXFAttr(291, default=1), # true/false
  439. 'align_direction': DXFAttr(292, default=1), # true/false
  440. 'simple_surfaces': DXFAttr(293, default=1), # true/false
  441. 'closed_surfaces': DXFAttr(294, default=0), # true/false
  442. 'solid': DXFAttr(295, default=0), # true/false
  443. 'ruled_surface': DXFAttr(296, default=0), # true/false
  444. 'virtual_guide': DXFAttr(297, default=0), # true/false
  445. })
  446. class LoftedSurface(Surface):
  447. __slots__ = ()
  448. TEMPLATE = ExtendedTags.from_text(_LOFTEDSURFACE_TPL)
  449. CLASS = (
  450. ExtendedTags.from_text(_LOFTEDSURFACE_CLS),
  451. ExtendedTags.from_text(_ACDBASSOCLOFTEDSURFACEACTIONBODY_CLS),
  452. )
  453. DXFATTRIBS = DXFAttributes(
  454. none_subclass,
  455. entity_subclass,
  456. modeler_geometry_subclass,
  457. surface_subclass,
  458. lofted_surface_subclass,
  459. )
  460. def set_transformation_matrix_lofted_entity(self, matrix: 'Matrix44') -> None:
  461. self._set_matrix(code=40, data=matrix)
  462. def get_transformation_matrix_lofted_entity(self) -> 'Matrix44':
  463. return self._get_matrix(code=40)
  464. _REVOLVEDSURFACE_TPL = """0
  465. REVOLVEDSURFACE
  466. 5
  467. 0
  468. 330
  469. 0
  470. 100
  471. AcDbEntity
  472. 8
  473. 0
  474. 100
  475. AcDbModelerGeometry
  476. 70
  477. 1
  478. 100
  479. AcDbSurface
  480. 71
  481. 0
  482. 72
  483. 0
  484. 100
  485. AcDbRevolvedSurface
  486. 90
  487. 36
  488. 10
  489. 0.0
  490. 20
  491. 0.0
  492. 30
  493. 0.0
  494. 11
  495. 0.0
  496. 21
  497. 0.0
  498. 31
  499. 1.0
  500. 40
  501. 0.0
  502. 41
  503. 0.0
  504. 42
  505. 1.0
  506. 42
  507. 0.0
  508. 42
  509. 0.0
  510. 42
  511. 0.0
  512. 42
  513. 0.0
  514. 42
  515. 1.0
  516. 42
  517. 0.0
  518. 42
  519. 0.0
  520. 42
  521. 0.0
  522. 42
  523. 0.0
  524. 42
  525. 1.0
  526. 42
  527. 0.0
  528. 42
  529. 0.0
  530. 42
  531. 0.0
  532. 42
  533. 0.0
  534. 42
  535. 1.0
  536. 43
  537. 0.0
  538. 44
  539. 0.0
  540. 45
  541. 0.0
  542. 46
  543. 0.0
  544. 290
  545. 0
  546. 291
  547. 0
  548. """
  549. _REVOLVEDSURFACE_CLS = """0
  550. CLASS
  551. 1
  552. REVOLVEDSURFACE
  553. 2
  554. AcDbRevolvedSurface
  555. 3
  556. ObjectDBX Classes
  557. 90
  558. 0
  559. 91
  560. 2
  561. 280
  562. 0
  563. 281
  564. 1
  565. """
  566. _ACDBASSOCREVOLVEDSURFACEACTIONBODY_CLS = """0
  567. CLASS
  568. 1
  569. ACDBASSOCREVOLVEDSURFACEACTIONBODY
  570. 2
  571. AcDbAssocRevolvedSurfaceActionBody
  572. 3
  573. ObjectDBX Classes
  574. 90
  575. 1025
  576. 91
  577. 2
  578. 280
  579. 0
  580. 281
  581. 0
  582. """
  583. revolved_surface_subclass = DefSubclass('AcDbRevolvedSurface', {
  584. 'class_id': DXFAttr(90, default=0.),
  585. 'axis_point': DXFAttr(10, xtype=XType.point3d),
  586. 'axis_vector': DXFAttr(11, xtype=XType.point3d),
  587. 'revolve_angle': DXFAttr(40), # in radians
  588. 'start_angle': DXFAttr(41), # in radians
  589. # 16x group code 42: Transform matrix of revolved entity (16 floats; row major format; default = identity matrix)
  590. 'draft_angle': DXFAttr(43), # in radians
  591. 'start_draft_distance': DXFAttr(44, default=0),
  592. 'end_draft_distance': DXFAttr(45, default=0),
  593. 'twist_angle': DXFAttr(46, default=0), # in radians
  594. 'solid': DXFAttr(290, default=0), # true/false
  595. 'close_to_axis': DXFAttr(210, default=0), # true/false
  596. })
  597. class RevolvedSurface(Surface):
  598. __slots__ = ()
  599. TEMPLATE = ExtendedTags.from_text(_REVOLVEDSURFACE_TPL)
  600. CLASS = (
  601. ExtendedTags.from_text(_REVOLVEDSURFACE_CLS),
  602. ExtendedTags.from_text(_ACDBASSOCREVOLVEDSURFACEACTIONBODY_CLS),
  603. )
  604. DXFATTRIBS = DXFAttributes(
  605. none_subclass,
  606. entity_subclass,
  607. modeler_geometry_subclass,
  608. surface_subclass,
  609. revolved_surface_subclass,
  610. )
  611. def set_transformation_matrix_revolved_entity(self, matrix: 'Matrix44') -> None:
  612. self._set_matrix(code=42, data=matrix)
  613. def get_transformation_matrix_revolved_entity(self) -> 'Matrix44':
  614. return self._get_matrix(code=42)
  615. _SWEPTSURFACE_TPL = """0
  616. SWEPTSURFACE
  617. 5
  618. 0
  619. 330
  620. 0
  621. 100
  622. AcDbEntity
  623. 8
  624. 0
  625. 100
  626. AcDbModelerGeometry
  627. 70
  628. 1
  629. 100
  630. AcDbSurface
  631. 71
  632. 0
  633. 72
  634. 0
  635. 100
  636. AcDbSweptSurface
  637. 90
  638. 36
  639. 91
  640. 36
  641. 40
  642. 1.0
  643. 40
  644. 0.0
  645. 40
  646. 0.0
  647. 40
  648. 0.0
  649. 40
  650. 0.0
  651. 40
  652. 1.0
  653. 40
  654. 0.0
  655. 40
  656. 0.0
  657. 40
  658. 0.0
  659. 40
  660. 0.0
  661. 40
  662. 1.0
  663. 40
  664. 0.0
  665. 40
  666. 0.0
  667. 40
  668. 0.0
  669. 40
  670. 0.0
  671. 40
  672. 1.0
  673. 41
  674. 1.0
  675. 41
  676. 0.0
  677. 41
  678. 0.0
  679. 41
  680. 0.0
  681. 41
  682. 0.0
  683. 41
  684. 1.0
  685. 41
  686. 0.0
  687. 41
  688. 0.0
  689. 41
  690. 0.0
  691. 41
  692. 0.0
  693. 41
  694. 1.0
  695. 41
  696. 0.0
  697. 41
  698. 0.0
  699. 41
  700. 0.0
  701. 41
  702. 0.0
  703. 41
  704. 1.0
  705. 42
  706. 0.0
  707. 43
  708. 0.0
  709. 44
  710. 0.0
  711. 45
  712. 0.0
  713. 48
  714. 1.0
  715. 49
  716. 0.0
  717. 46
  718. 1.0
  719. 46
  720. 0.0
  721. 46
  722. 0.0
  723. 46
  724. 0.0
  725. 46
  726. 0.0
  727. 46
  728. 1.0
  729. 46
  730. 0.0
  731. 46
  732. 0.0
  733. 46
  734. 0.0
  735. 46
  736. 0.0
  737. 46
  738. 1.0
  739. 46
  740. 0.0
  741. 46
  742. 0.0
  743. 46
  744. 0.0
  745. 46
  746. 0.0
  747. 46
  748. 1.0
  749. 47
  750. 1.0
  751. 47
  752. 0.0
  753. 47
  754. 0.0
  755. 47
  756. 0.0
  757. 47
  758. 0.0
  759. 47
  760. 1.0
  761. 47
  762. 0.0
  763. 47
  764. 0.0
  765. 47
  766. 0.0
  767. 47
  768. 0.0
  769. 47
  770. 1.0
  771. 47
  772. 0.0
  773. 47
  774. 0.0
  775. 47
  776. 0.0
  777. 47
  778. 0.0
  779. 47
  780. 1.0
  781. 290
  782. 0
  783. 70
  784. 1
  785. 71
  786. 2
  787. 292
  788. 0
  789. 293
  790. 0
  791. 294
  792. 1
  793. 295
  794. 1
  795. 296
  796. 1
  797. 11
  798. 0.0
  799. 21
  800. 0.0
  801. 31
  802. 0.0
  803. """
  804. _SWEPTSURFACE_CLS = """0
  805. CLASS
  806. 1
  807. SWEPTSURFACE
  808. 2
  809. AcDbSweptSurface
  810. 3
  811. ObjectDBX Classes
  812. 90
  813. 0
  814. 91
  815. 0
  816. 280
  817. 0
  818. 281
  819. 1
  820. """
  821. _ACDBASSOCSWEPTSURFACEACTIONBODY_CLS = """0
  822. CLASS
  823. 1
  824. ACDBASSOCSWEPTSURFACEACTIONBODY
  825. 2
  826. AcDbAssocSweptSurfaceActionBody
  827. 3
  828. ObjectDBX Classes
  829. 90
  830. 1025
  831. 91
  832. 0
  833. 280
  834. 0
  835. 281
  836. 0
  837. """
  838. swept_surface_subclass = DefSubclass('AcDbSweptSurface', {
  839. 'swept_entity_id': DXFAttr(90),
  840. 'path_entity_id': DXFAttr(91),
  841. # 16x group code 40: Transform matrix of sweep entity (16 floats; row major format; default = identity matrix)
  842. # 16x group code 41: Transform matrix of path entity (16 floats; row major format; default = identity matrix)
  843. # don't know the meaning of this matrices
  844. # 16x group code 46: Transform matrix of sweep entity (16 floats; row major format; default = identity matrix)
  845. # 16x group code 47: Transform matrix of path entity (16 floats; row major format; default = identity matrix)
  846. 'draft_angle': DXFAttr(42), # in radians
  847. 'draft_start_distance': DXFAttr(43, default=0),
  848. 'draft_end_distance': DXFAttr(44, default=0),
  849. 'twist_angle': DXFAttr(45, default=0), # in radians
  850. 'scale_factor': DXFAttr(48, default=1),
  851. 'align_angle': DXFAttr(49, default=0), # in radians
  852. 'solid': DXFAttr(90, default=0), # in radians
  853. 'sweep_alignment': DXFAttr(70, default=0), # 0=No alignment; 1= align sweep entity to path;
  854. # 2=Translate sweep entity to path; 3=Translate path to sweep entity
  855. 'align_start': DXFAttr(292, default=0), # true/false
  856. 'bank': DXFAttr(293, default=0), # true/false
  857. 'base_point_set': DXFAttr(294, default=0), # true/false
  858. 'sweep_entity_transform_computed': DXFAttr(295, default=0), # true/false
  859. 'path_entity_transform_computed': DXFAttr(296, default=0), # true/false
  860. 'reference_vector_for_controlling_twist': DXFAttr(11, xtype=XType.point3d),
  861. })
  862. class SweptSurface(Surface):
  863. __slots__ = ()
  864. TEMPLATE = ExtendedTags.from_text(_SWEPTSURFACE_TPL)
  865. CLASS = (
  866. ExtendedTags.from_text(_SWEPTSURFACE_CLS),
  867. ExtendedTags.from_text(_ACDBASSOCSWEPTSURFACEACTIONBODY_CLS),
  868. )
  869. DXFATTRIBS = DXFAttributes(
  870. none_subclass,
  871. entity_subclass,
  872. modeler_geometry_subclass,
  873. surface_subclass,
  874. swept_surface_subclass,
  875. )
  876. def set_transformation_matrix_sweep_entity(self, matrix: 'Matrix44') -> None:
  877. self._set_matrix(code=40, data=matrix)
  878. def get_transformation_matrix_sweep_entity(self) -> 'Matrix44':
  879. return self._get_matrix(code=40)
  880. def set_transformation_matrix_path_entity(self, matrix: 'Matrix44') -> None:
  881. self._set_matrix(code=41, data=matrix)
  882. def get_transformation_matrix_path_entity(self) -> 'Matrix44':
  883. return self._get_matrix(code=41)
  884. # don't know the meaning of this matrices
  885. def set_sweep_entity_transformation_matrix(self, matrix: 'Matrix44') -> None:
  886. self._set_matrix(code=46, data=matrix)
  887. def get_sweep_entity_transformation_matrix(self) -> 'Matrix44':
  888. return self._get_matrix(code=46)
  889. def set_path_entity_transformation_matrix(self, matrix: 'Matrix44') -> None:
  890. self._set_matrix(code=47, data=matrix)
  891. def get_path_entity_transformation_matrix(self) -> 'Matrix44':
  892. return self._get_matrix(code=47)
  893. _PLANESURFACE_CLS = """0
  894. CLASS
  895. 1
  896. PLANESURFACE
  897. 2
  898. AcDbPlaneSurface
  899. 3
  900. ObjectDBX Classes
  901. 90
  902. 4095
  903. 91
  904. 0
  905. 280
  906. 0
  907. 281
  908. 1
  909. """
  910. # TODO: related by a handle to any surface entity
  911. _NURBSURFACE_CLS = """0
  912. CLASS
  913. 1
  914. NURBSURFACE
  915. 2
  916. AcDbNurbSurface
  917. 3
  918. ObjectDBX Classes
  919. 90
  920. 0
  921. 91
  922. 0
  923. 280
  924. 0
  925. 281
  926. 1
  927. """