Author Topic: Help with a lisp : Lenght Of Object  (Read 1348 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Guest
Help with a lisp : Lenght Of Object
« on: December 06, 2020, 03:21:26 AM »
I have this code to dimension lines. arc,polylines . The problem is that calculate the full length. So when i have 4 points on an arc or on a polyline i can not find the distance between them. I want to ask if it possible to make this lisp work like this

1) select the object (so understand if it is a polyline ,or line or acr etc...)
2) give as the otion to hit ender and calculate all the distanse or
3) give as the option to pick 2 points and aclulate the dinstanse from this area only


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

Thanks

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Help with a lisp : Lenght Of Object
« Reply #1 on: December 07, 2020, 01:29:23 AM »
Over at forum\autodesk kent1cooper has some very good dim pline etc may be what your looking for.
A man who never made a mistake never made anything

JarvisDashiell

  • Mosquito
  • Posts: 2
Re: Help with a lisp : Lenght Of Object
« Reply #2 on: December 17, 2020, 11:34:33 PM »
 :lol: :lol:
แทงบอล
ดูบอลสดฟรี