Author Topic: Create Dynamic Block  (Read 2416 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
Create Dynamic Block
« on: December 29, 2016, 01:53:18 PM »
Hi guys,
Shortly my question would be is it possible to create an dynamic block parameter (point/linear/polar/rotation...).
Obviously theres no method to invoke that creates it (like one would do with line/polyline/circle/text/mtext...).

Heres a dump on a block definition:
Code - Text: [Select]
  1. _$ (vlax-dump-object BlockObj T)
  2. ; IAcadBlock: A block definition containing a name and a set of objects
  3. ; Property values:
  4. ;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff7d08a9110>
  5. ;   BlockScaling = 0
  6. ;   Comments = ""
  7. ;   Count (RO) = 2
  8. ;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000d8ba2bbe78>
  9. ;   Explodable = -1
  10. ;   Handle (RO) = "3AE"
  11. ;   HasExtensionDictionary (RO) = 0
  12. ;   IsDynamicBlock (RO) = 0
  13. ;   IsLayout (RO) = 0
  14. ;   IsXRef (RO) = 0
  15. ;   Layout (RO) = AutoCAD.Application: The property is not available in current state
  16. ;   Name = "bada"
  17. ;   ObjectID (RO) = 62
  18. ;   ObjectName (RO) = "AcDbBlockTableRecord"
  19. ;   Origin = (0.0 0.0 0.0)
  20. ;   OwnerID (RO) = 63
  21. ;   Path = AutoCAD.Application: Not applicable
  22. ;   Units = 0
  23. ;   XRefDatabase (RO) = AutoCAD.Application: No database
  24. ; Methods supported:
  25. ;   Add3DFace (4)
  26. ;   Add3DMesh (3)
  27. ;   Add3DPoly (1)
  28. ;   AddArc (4)
  29. ;   AddAttribute (6)
  30. ;   AddBox (4)
  31. ;   AddCircle (2)
  32. ;   AddCone (3)
  33. ;   AddCustomObject (1)
  34. ;   AddCylinder (3)
  35. ;   AddDim3PointAngular (4)
  36. ;   AddDimAligned (3)
  37. ;   AddDimAngular (4)
  38. ;   AddDimArc (4)
  39. ;   AddDimDiametric (3)
  40. ;   AddDimOrdinate (3)
  41. ;   AddDimRadial (3)
  42. ;   AddDimRadialLarge (5)
  43. ;   AddDimRotated (4)
  44. ;   AddEllipse (3)
  45. ;   AddEllipticalCone (4)
  46. ;   AddEllipticalCylinder (4)
  47. ;   AddExtrudedSolid (3)
  48. ;   AddExtrudedSolidAlongPath (2)
  49. ;   AddHatch (4)
  50. ;   AddLeader (3)
  51. ;   AddLightWeightPolyline (1)
  52. ;   AddLine (2)
  53. ;   AddMInsertBlock (11)
  54. ;   AddMLeader (2)
  55. ;   AddMLine (1)
  56. ;   AddMText (3)
  57. ;   AddPoint (1)
  58. ;   AddPolyfaceMesh (2)
  59. ;   AddPolyline (1)
  60. ;   AddRaster (4)
  61. ;   AddRay (2)
  62. ;   AddRegion (1)
  63. ;   AddRevolvedSolid (4)
  64. ;   AddSection (3)
  65. ;   AddShape (4)
  66. ;   AddSolid (4)
  67. ;   AddSphere (2)
  68. ;   AddSpline (3)
  69. ;   AddTable (5)
  70. ;   AddText (3)
  71. ;   AddTolerance (3)
  72. ;   AddTorus (3)
  73. ;   AddTrace (1)
  74. ;   AddWedge (4)
  75. ;   AddXline (2)
  76. ;   AttachExternalReference (9)
  77. ;   Bind (1)
  78. ;   Delete ()
  79. ;   Detach ()
  80. ;   GetExtensionDictionary ()
  81. ;   GetXData (3)
  82. ;   InsertBlock (7)
  83. ;   Item (1)
  84. ;   Reload ()
  85. ;   SetXData (2)
  86. ;   Unload ()
  87.  

Heres a dump on a linear parameter that I want to create:
Code - Text: [Select]
  1. _$ (vlax-dump-object (vlax-ename->vla-object (car (entsel))) T)
  2. ; IAcadBlockLinearParameterEntity: IAcadBlockLinearParameterEntity Interface
  3. ; Property values:
  4. ;   Angle (RO) = 0.0
  5. ;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff7d08a9110>
  6. ;   BaseLocation = 0
  7. ;   BasePoint = (0.0 0.0 0.0)
  8. ;   ChainActions = 0
  9. ;   Distance = 200.0
  10. ;   DistanceDesc = ""
  11. ;   DistName = "Distance1"
  12. ;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000d8ba2bbe78>
  13. ;   EndPoint = (200.0 0.0 0.0)
  14. ;   EntityTransparency = "ByLayer"
  15. ;   Grips = 1
  16. ;   Handle (RO) = "3A6"
  17. ;   HasExtensionDictionary (RO) = 0
  18. ;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000000e0bfc8ba78>
  19. ;   LabelDist = -15.5303
  20. ;   Layer = "0"
  21. ;   Linetype = "ByLayer"
  22. ;   LinetypeScale = 1.0
  23. ;   Lineweight = -1
  24. ;   Material = "ByLayer"
  25. ;   Name = "Linear"
  26. ;   ObjectID (RO) = 59
  27. ;   ObjectName (RO) = "AcDbBlockLinearParameterEntity"
  28. ;   OwnerID (RO) = 60
  29. ;   PlotStyleName = "ByLayer"
  30. ;   ShowProperties = -1
  31. ;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000000e0bfc8ad50>
  32. ;   ValueSetIncrement = Exception occurred
  33. ;   ValueSetList = Exception occurred
  34. ;   ValueSetMax = 0.0
  35. ;   ValueSetMin = 0.0
  36. ;   ValueSetType = 0
  37. ;   Visible = -1
  38. ; Methods supported:
  39. ;   ArrayPolar (3)
  40. ;   ArrayRectangular (6)
  41. ;   Copy ()
  42. ;   Delete ()
  43. ;   GetBoundingBox (2)
  44. ;   GetExtensionDictionary ()
  45. ;   GetXData (3)
  46. ;   Highlight (1)
  47. ;   IntersectWith (2)
  48. ;   Mirror (2)
  49. ;   Mirror3D (3)
  50. ;   Move (2)
  51. ;   Rotate (2)
  52. ;   Rotate3D (3)
  53. ;   ScaleEntity (2)
  54. ;   SetXData (2)
  55. ;   TransformBy (1)
  56. ;   Update ()
  57.  

I've wrote something to check atleast where these stuff are stored (and found their enames under "ACAD_EVALUATION_GRAPH" dictionary):
Code - Text: [Select]
  1. (defun test ( / e o nm enx next LstEnames LstObjs )
  2.   (if
  3.     (and
  4.       (setq e (car (entsel "\nSelect the block: ")))
  5.       (setq o (vlax-ename->vla-object e))
  6.       (eq (vla-get-ObjectName o) "AcDbBlockReference")
  7.       (eq (vla-get-IsDynamicBlock o) :vlax-true)
  8.     )
  9.     (progn
  10.       (setq nm (vla-get-EffectiveName o))
  11.       (setq enx (entget (tblobjname "BLOCK" nm)))
  12.       (setq next (tblobjname "BLOCK" nm))
  13.       (while (and (setq next (entnext next)) (/= "ENDBLK" (cdr (assoc 0 (entget next)))))
  14.         (setq LstEnames (cons next LstEnames))
  15.       )
  16.       (vlax-for x (setq BlkDefObj (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) nm))
  17.         (setq LstObjs (cons x LstObjs))
  18.       )
  19.       (print (mapcar '(lambda (x) (cdr (assoc 0 (entget x)))) LstEnames))
  20.       (print (mapcar '(lambda (x) (vla-get-ObjectName x)) LstObjs))
  21.       (vlax-for x (setq extDictObj (vlax-invoke BlkDefObj 'GetExtensionDictionary))
  22.         (setq LstExtObjs (cons x LstExtObjs))
  23.       )
  24.       (setq extDictEnx (entget (handent (vla-get-Handle extDictObj))))
  25.       (setq ACAD_EVALUATION_GRAPH (entget (cdr (cadr (member (cons 3 "ACAD_ENHANCEDBLOCK") extDictEnx)))))
  26.       (setq PrmsLst (vl-remove-if-not (function (lambda (x) (= 360 (car x)))) ACAD_EVALUATION_GRAPH))
  27.       (setq PrmsLst (mapcar 'entget (mapcar 'cdr PrmsLst)))
  28.       (foreach x (mapcar '(lambda (x) (cdr (assoc 0 x))) PrmsLst) (print x))
  29.     )
  30.   )
  31.   (princ)
  32. )
Print Result:
Code - Text: [Select]
  1.  
  2. _$ (test)
  3.  
  4. ("ATTDEF" "ATTDEF" "ATTDEF" "INSERT" "INSERT" "INSERT" "INSERT" "LINE" "LINE" "LWPOLYLINE")
  5. ("AcDbAttributeDefinition" "AcDbAttributeDefinition" "AcDbAttributeDefinition" "AcDbBlockReference" "AcDbBlockReference" "AcDbBlockReference" "AcDbBlockReference" "AcDbLine" "AcDbLine" "AcDbPolyline")
  6. "BLOCKLINEARPARAMETER"
  7. "BLOCKLINEARGRIP"
  8. "BLOCKGRIPLOCATIONCOMPONENT"
  9. "BLOCKGRIPLOCATIONCOMPONENT"
  10. "BLOCKLINEARPARAMETER"
  11. "BLOCKLINEARGRIP"
  12. "BLOCKGRIPLOCATIONCOMPONENT"
  13. "BLOCKGRIPLOCATIONCOMPONENT"
  14. "BLOCKLINEARPARAMETER"
  15. "BLOCKLINEARGRIP"
  16. "BLOCKGRIPLOCATIONCOMPONENT"
  17. "BLOCKGRIPLOCATIONCOMPONENT"
  18. "BLOCKLINEARPARAMETER"
  19. "BLOCKLINEARGRIP"
  20. "BLOCKGRIPLOCATIONCOMPONENT"
  21. "BLOCKGRIPLOCATIONCOMPONENT"
  22. "BLOCKSTRETCHACTION"
  23. "BLOCKSTRETCHACTION"
  24. "BLOCKSTRETCHACTION"
  25. "BLOCKSTRETCHACTION"
  26. _$
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg