Author Topic: vla-put-textposition and dimensions  (Read 1950 times)

0 Members and 1 Guest are viewing this topic.

Rabbit

  • Guest
vla-put-textposition and dimensions
« on: October 20, 2014, 02:32:24 PM »
I'm having trouble with setting the text location of a dimension using lisp.  While the routine cycles through, the Block inserts and shows up, but, the dimensions don't show up right away.  When I use vla-put-textposition to set the position, I'm using (entlast) to get the continued dimension.  (entlast) returns the block and not the 1st dimension.  I think it has something to do with the dimension not immediately showing up in the drawing.  I've added (command "regen") in between the call for dimcontinue and vla-put-textposition, which does not solve the problem.

Code - Auto/Visual Lisp: [Select]
  1. (command "-insert" "BLOCKNAME" "non" pnt1 1 1 0.0)
  2. (setq Block (entlast))
  3.  
  4. ;First point of dim is at a given point.
  5. ;Second point of dim is from insertion point of Block, go up 6" and to the left 1".
  6. ;The last point places the dimension at 36" below the insertion point of the block.
  7. (command "dimlinear" "end" pnt2 "end" (polar (polar (cdr (assoc 10 (entget Block))) pi 1.0) 1.5708 6.0) "non" (polar (cdr (assoc 10 (entget Block))) 4.71239 24.0))
  8.  
  9. ;Continue dimension to the right of last point of previous dimension by 2".
  10. ;The insertion point of the continued dimension is from insertion point of Block, go up 6" and to the right 1".
  11. (command "dimcontinue" "end" (polar (polar (cdr (assoc 10 (entget Block))) 0.0 1.0) 1.5708 6.0) "" "");do 2" dim.
  12.  
  13. ;Put 2" dimension text in a place that is easier to read.
  14. ;The text is moved to a point that is 36" down and 6" to the right of the Block's insertion point.
  15. (vla-put-textposition (vlax-ename->vla-object (entlast)) (vlax-3D-point (polar (polar (cdr (assoc 10 (entget Block))) 4.71239 36.0) 0.0 6.0)))
  16.  

I also tried using the following to create the 2nd dimension, but I need the dimension to be associative to the block.  Hence the calls to "end" in my command sequence in the code above.  I'd rather use the code above for this reason, but, if there is a way using the code below, and keep the dimensions associative, I'm open to that also.  Of course, I still have the problem with (entlast).
Code - Auto/Visual Lisp: [Select]
  1. (setq DimObj (vla-adddimrotated ModelSpace
  2.   (vlax-3D-point (cdr (assoc 14 (entget (entlast)))));Get last point of 1st dimension to place 1st point of new dimension.
  3.   (vlax-3D-point (polar (cdr (assoc 14 (entget (entlast)))) 0.0 2.0));Place second point of new dimension 2" to the right of last point of 1st dimension.
  4.   (vlax-3D-point (polar (cdr (assoc 10 (entget Block))) 4.71239 24.0) 0.0));The last point places the dimension at 36" below the insertion point of the block.
  5.