Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Re: LM:blockreferenceboundingbox
« Last post by domenicomaria on Today at 08:19:19 AM »
Marco,
don't you think that maybe there is good reason
to explain the difference between
your code
and LM:blockreferenceboundingbox of Lee Mac ?

I suppose that the Lee Mac code, works also for rotated and not uniformly scaled inserts . . .

Code - Auto/Visual Lisp: [Select]
  1. ;; Block Reference Bounding Box  -  Lee Mac
  2. ;; Returns a WCS point list describing a rectangular frame bounding all geometry of a supplied block reference.
  3. ;; Excludes Text, MText & Attribute Definitions.
  4. ;; ref - [vla] Block Reference Object
  5.  
  6. (defun LM:blockreferenceboundingbox ( ref )
  7.     (
  8.         (lambda ( lst )
  9.             (apply
  10.                 (function
  11.                     (lambda ( m v )
  12.                         (mapcar (function (lambda ( p ) (mapcar '+ (mxv m p) v))) lst)
  13.                     )
  14.                 )
  15.                 (refgeom (vlax-vla-object->ename ref))
  16.             )
  17.         )
  18.         (LM:blockdefinitionboundingbox
  19.             (vla-item
  20.                 (vla-get-blocks (vla-get-document ref))
  21.                 (vla-get-name ref)
  22.             )
  23.         )
  24.     )
  25. )
  26.  
  27. ;; Block Definition Bounding Box  -  Lee Mac
  28. ;; Returns a WCS point list describing a rectangular frame bounding all geometry of a supplied block definition.
  29. ;; Excludes Text, MText & Attribute Definitions.
  30. ;; def - [vla] Block Definition Object
  31.  
  32. (defun LM:blockdefinitionboundingbox ( def / llp lst urp )
  33.     (vlax-for obj def
  34.         (cond
  35.             (   (= :vlax-false (vla-get-visible obj)))
  36.             (   (= "AcDbBlockReference" (vla-get-objectname obj))
  37.                 (setq lst (append lst (LM:blockreferenceboundingbox obj)))
  38.             )
  39.             (   (and (not (wcmatch (vla-get-objectname obj) "AcDbAttributeDefinition,AcDb*Text"))
  40.                      (vlax-method-applicable-p obj 'getboundingbox)
  41.                      (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp))))
  42.                 )
  43.                 (setq lst (vl-list* (vlax-safearray->list llp) (vlax-safearray->list urp) lst))
  44.             )
  45.         )
  46.     )
  47.     (LM:points->boundingbox lst)
  48. )
  49.  
  50. ;; Point to Bounding Box  -  Lee Mac
  51. ;; Returns the rectangular extents of a supplied point list
  52.  
  53. (defun LM:points->boundingbox ( lst )
  54.     (   (lambda ( l )
  55.             (mapcar '(lambda ( a ) (mapcar '(lambda ( b ) ((eval b) l)) a))
  56.                '(
  57.                     (caar   cadar)
  58.                     (caadr  cadar)
  59.                     (caadr cadadr)
  60.                     (caar  cadadr)
  61.                 )
  62.             )
  63.         )
  64.         (mapcar '(lambda ( f ) (apply 'mapcar (cons f lst))) '(min max))
  65.     )
  66. )
  67.  
  68. ;; RefGeom (gile)
  69. ;; Returns a list which first item is a 3x3 transformation matrix (rotation, scales, normal)
  70. ;; and second item the object insertion point in its parent (xref, block or space)
  71. ;; Argument : an ename
  72.  
  73. (defun refgeom ( ent / ang ang mat ocs )
  74.     (setq enx (entget ent)
  75.           ang (cdr (assoc 050 enx))
  76.           ocs (cdr (assoc 210 enx))
  77.     )
  78.     (list
  79.         (setq mat
  80.             (mxm
  81.                 (mapcar '(lambda ( v ) (trans v 0 ocs t))
  82.                    '(
  83.                         (1.0 0.0 0.0)
  84.                         (0.0 1.0 0.0)
  85.                         (0.0 0.0 1.0)
  86.                     )
  87.                 )
  88.                 (mxm
  89.                     (list
  90.                         (list (cos ang) (- (sin ang)) 0.0)
  91.                         (list (sin ang) (cos ang)     0.0)
  92.                        '(0.0 0.0 1.0)
  93.                     )
  94.                     (list
  95.                         (list (cdr (assoc 41 enx)) 0.0 0.0)
  96.                         (list 0.0 (cdr (assoc 42 enx)) 0.0)
  97.                         (list 0.0 0.0 (cdr (assoc 43 enx)))
  98.                     )
  99.                 )
  100.             )
  101.         )
  102.         (mapcar '- (trans (cdr (assoc 10 enx)) ocs 0)
  103.             (mxv mat (cdr (assoc 10 (tblsearch "block" (cdr (assoc 2 enx))))))
  104.         )
  105.     )
  106. )
  107.  
  108. ;; Matrix x Vector - Vladimir Nesterovsky
  109. ;; Args: m - nxn matrix, v - vector in R^n
  110.  
  111. (defun mxv ( m v )
  112.     (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
  113. )
  114.  
  115. ;; Matrix Transpose - Doug Wilson
  116. ;; Args: m - nxn matrix
  117.  
  118. (defun trp ( m )
  119.     (apply 'mapcar (cons 'list m))
  120. )
  121.  
  122. ;; Matrix x Matrix - Vladimir Nesterovsky
  123. ;; Args: m,n - nxn matrices
  124.  
  125. (defun mxm ( m n )
  126.     ((lambda ( a ) (mapcar '(lambda ( r ) (mxv a r)) m)) (trp n))
  127. )
2
AutoLISP (Vanilla / Visual) / Re: Draw a point with especific distance
« Last post by Lee Mac on Today at 05:53:28 AM »
There is not anything wrong about the code.

It is insert a point to x=1 and y=1. But in some case ins't working properly, just like the example bellow

Align your UCS with the surrounding geometry, and then use my program to calculate & create a point offset by 1,1 relative to the current UCS.
3
What's the result with this?
Code: [Select]
(defun ALE_Utl_GetBoundingBox (VlaObj / LowLft UppRgt)
  (vl-catch-all-apply
    'vla-GetBoundingBox (list VlaObj 'LowLft 'UppRgt)
  )
  (if LowLft
    (mapcar 'vlax-safearray->list (list LowLft UppRgt))
  )
)
4
Here is the block and definitions about parameters and attributes.

I am fully astonished understanding the behavior of AutoCAD to use them in Dynamic Blocks.

I draw a table in Excel showing the parameters and attributes and their values. It is enclosed too.
5
I think you'll find it easier to use a piece of text with a field value than with an attribute (I say this from my own experience).

If you want to post your WIP block I'm sure I or someone else will be able to take a look for you.

dJE
One more comment...

When inserting TEXT or MTEXT, there is no any way to insert (or refer to) variables defined within the block, it is just possible in ATTDEF.


It works through fields. When you send post your sample block Iíll show you.

dJE
6
It should work if it was created in that drawing.

If an object and a text or attribute with a field referencing it were inserted into another drawing the field's link would be broken since the object and it's ID would be different in the new drawing.

If you were to make multiple copies of an object with a field referencing it all the fields would reference the original object and it that object was deleted it would break the reference to all the copied fields.
tombu, thank you for info, but I just now defined a new bare block, with not any success...

I will send the block in other post.
7
I think you'll find it easier to use a piece of text with a field value than with an attribute (I say this from my own experience).

If you want to post your WIP block I'm sure I or someone else will be able to take a look for you.

dJE
One more comment...

When inserting TEXT or MTEXT, there is no any way to insert (or refer to) variables defined within the block, it is just possible in ATTDEF.
8
I think you'll find it easier to use a piece of text with a field value than with an attribute (I say this from my own experience).

If you want to post your WIP block I'm sure I or someone else will be able to take a look for you.

dJE
Daniel, I did your mentioned instructions, but the text shows the word "UserVariable" instead of the real value of the selected attribute.

I will send a sample of my all unsuccessful efforts in another post.
9
AutoLISP (Vanilla / Visual) / Re: LM:blockreferenceboundingbox
« Last post by domenicomaria on Today at 01:15:43 AM »
The LEFT YELLOW rectangle,
is the SAME RIGTH YELLOW rectangle

the ONLY DIFFERENCE is that it is ROTATED !

While the GREEN LEFT rectangle,
is the TRUE BOUNDING BOX of the ROTATED BLOCK REFERENCE.

10
Oooh, I didn't know that!

So do you have Friday/Saturday off work and work Sunday-Thursday?

dJE

No, Thurseday and Friday are off days.
Pages: [1] 2 3 ... 10