Author Topic: Length line with annotation tex.-Help with a lisp  (Read 1723 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
Length line with annotation tex.-Help with a lisp
« on: March 06, 2020, 01:54:09 PM »
Hi i am using this lisp code to dimension lines in my topografic drawings . The problem is that this code don't work as i want with the text sizes. For example i want fo 1:100m  ht = 0.175 ,1:200m ht=0.35 , 1:500 ht =0.875. The problem is in this line


Code - Auto/Visual Lisp: [Select]
  1. (setq TxtObj (vla-addText *ModelSpace* (rtos olg 2 2) (vlax-3d-point midpt) (* (getvar"textsize") 0.2))) ;_ end of vla-addText
  2.  


the 0.2 say to the code that me default scale is 1:200m and gives me wrong ht. (ht= the text height). I want to understand the scale every time but i don't   know how to change this line.

Code - Auto/Visual Lisp: [Select]
  1. ;------------------------------------------------ LenghtOfObject --------------
  2. (defun LenghtOfObject (obj / len)
  3. (list obj (vl-catch-all-apply 'vlax-curve-getEndParam (list obj)))))) nil len
  4. )
  5. )
  6. ;------------------------------------------------ c:LengthText ----------------
  7. (defun c:LineDimAnnot ( / *ModelSpace* sel)
  8.   (command "_.-layer" "_make" "lenght" "_color" 93 "" "_lweight" 0.30 "" "")
  9.   (command "_.-style" "_diast" "wgsimpl.shx" "_annotative" "_yes" "_no" 1.75 1.0 0.0 "_no" "_no" "_no")
  10. (setvar "errno" 0) ; when the user on ssget press Enter the errno is set to 52
  11. (while (and (setq sel (ssget))(/= (getvar "errno") 52))
  12. (if sel
  13. (mapcar (function (lambda (ent / obj olg stpt endpt next_pt midpt TxtObj midpt1)
  14. (setq Obj (vlax-ename->vla-object ent))
  15. (if (and (setq olg (LenghtOfObject obj))(> olg 0))
  16. (setq midPt (vlax-curve-getPointAtDist obj (* olg 0.5)))
  17. (setq midPt1 (polar midPt (+ (* 0.5 pi)(angle stpt endpt)) 1e-3))
  18. (setq TxtObj (vla-addText *ModelSpace* (rtos olg 2 2) (vlax-3d-point midpt) (* (getvar"textsize") 0.2))) ;_ end of vla-addText
  19. (vla-put-Rotation TxtObj (+ (* 1.5 pi)(angle (vlax-curve-getClosestPointTo obj midpt1) midpt1)))
  20. (setq midpt (vla-get-InsertionPoint TxtObj))
  21. (vla-put-alignment TxtObj acAlignmentBottomCenter)
  22. )
  23. (if (ssmemb ent sel)(ssdel ent sel))
  24. )
  25. ))(vl-remove-if-not '(lambda(x)(= (type x) 'ENAME)) (mapcar 'cadr (ssnamex sel))))
  26. )
  27. )
  28. )
  29. ;change layer to 0
  30. (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
  31. )
  32.  
  33.  

I appload a test file dwg to use my annotation scales because i work in meters


Thanks

PM

  • Guest
Re: Length line with annotation tex.-Help with a lisp
« Reply #1 on: March 07, 2020, 03:08:58 AM »
any ideas ?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Length line with annotation tex.-Help with a lisp
« Reply #2 on: March 07, 2020, 03:18:22 AM »
Here is a very basic idea: Start by properly indenting your code.
This will not solve your issue but may inspire others to actually read your code.

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Length line with annotation tex.-Help with a lisp
« Reply #3 on: March 07, 2020, 08:58:30 AM »
Replace
Code: [Select]
(* (getvar"textsize") 0.2)with
Code: [Select]
(* (/ 1. (getvar 'cannoscalevalue)) 0.175)
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

PM

  • Guest
Re: Length line with annotation tex.-Help with a lisp
« Reply #4 on: March 08, 2020, 06:45:34 PM »
Thanks you tombu

I check your code and i find that this work fine

Code - Auto/Visual Lisp: [Select]
  1. (* (/ 1. (getvar 'cannoscalevalue)) 1.75)


Thanks