Author Topic: Get architectural units?  (Read 220 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 1990
Get architectural units?
« on: July 15, 2019, 06:14:05 PM »
How would I modify the code to get architectural units? Sorry I don't know the original author?

;;objText      (vlax-invoke  objBlock "addtext" (vl-princ-to-string (- sngDistance1 sngDistance0)) lstMidPoint 9.6)
objText      (vlax-invoke  objBlock "addtext" (vl-princ-to-string (- (/ sngDistance1 12) (/ sngDistance0 12))) lstMidPoint 9.6)

Code: [Select]
(defun C:TextPL (/ lstMidPoint
                   obj
                   objBlock
                   objDocument
                   objText
                   sngDistance0
                   sngDistance1
                   sngParam
                 )
 (setq obj         (vlax-ename->vla-object (car (entsel "\nSelect Polyline: ")))
       objDocument (vla-get-activedocument (vlax-get-acad-object))
       objBlock    (vla-objectidtoobject objDocument (vla-get-ownerid obj))
 )
 (repeat (fix (setq sngParam (vlax-curve-getendparam obj)))
  (setq sngParam     (1- sngParam)
        lstPoint0    (vlax-curve-getpointatparam obj sngParam)
        sngDistance0 (vlax-curve-getdistatparam  obj sngParam)
        lstMidPoint  (vlax-curve-getpointatparam obj (+ sngParam 0.5))
        lstPoint1    (vlax-curve-getpointatparam obj (1+ sngParam))
        sngDistance1 (vlax-curve-getdistatparam  obj (1+ sngParam))
        objText      (vlax-invoke  objBlock "addtext" (vl-princ-to-string (- sngDistance1 sngDistance0)) lstMidPoint 9.6)
  )
  (vla-put-alignment objText 4)
  (vlax-invoke objText "move" (list 0.0 0.0 0.0) lstMidPoint)
  (vla-put-rotation  objText (angle lstPoint0 lstPOint1))

 )
 (princ)
)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 1990
Re: Get architectural units?
« Reply #1 on: July 15, 2019, 06:26:40 PM »
objText      (vlax-invoke  objBlock "addtext" (rtos (- (/ sngDistance1 12) (/ sngDistance0 12)) 4 6) lstMidPoint 9.6)

Now how do I get the dash inbetween the feet and inches?
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 1990
Re: Get architectural units?
« Reply #2 on: July 16, 2019, 08:53:34 AM »
duh...
(setvar "unitmode" 0)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

Tharwat

  • Swamp Rat
  • Posts: 517
  • Hypersensitive

GDF

  • Water Moccasin
  • Posts: 1990
Re: Get architectural units?
« Reply #4 on: July 16, 2019, 10:45:44 AM »
Thanks

I use this routine in my Design dialog box.

Updated code
Code: [Select]
(defun c:TextPt  ( / lstMidPoint
                   obj
                   objBlock
                   objDocument
                   objText
                   sngDistance0
                   sngDistance1
                   sngParam
                 )
 (ARCH:F_S-VAR)
 (setvar "LUNITS" 4)
 (setvar "unitmode" 0)
 (ARCH:LYR "AREA")
 (ARCH:SET-AREA2)
 (setq obj         (vlax-ename->vla-object (car (entsel "\n* Select Polyline: ")))
       objDocument (vla-get-activedocument (vlax-get-acad-object))
       objBlock    (vla-objectidtoobject objDocument (vla-get-ownerid obj))
 )
 (repeat (fix (setq sngParam (vlax-curve-getendparam obj)))
  (setq sngParam     (1- sngParam)
        lstPoint0    (vlax-curve-getpointatparam obj sngParam)
        sngDistance0 (vlax-curve-getdistatparam  obj sngParam)
        lstMidPoint  (vlax-curve-getpointatparam obj (+ sngParam 0.5))
        lstPoint1    (vlax-curve-getpointatparam obj (1+ sngParam))
        sngDistance1 (vlax-curve-getdistatparam  obj (1+ sngParam))
        ;;objText      (vlax-invoke  objBlock "addtext" (vl-princ-to-string (- sngDistance1 sngDistance0)) lstMidPoint 9.6)       
        objText      (vlax-invoke  objBlock "addtext" (rtos (- sngDistance1 sngDistance0) 4 (getvar "luprec")) lstMidPoint 9.6)
  )
  (vla-put-alignment objText 4)
  (vlax-invoke objText "move" (list 0.0 0.0 0.0) lstMidPoint)
  (vla-put-rotation  objText (angle lstPoint0 lstPOint1))
 )
 (ARCH:F_R-VAR)
 (princ)
)
« Last Edit: July 16, 2019, 11:16:58 AM by GDF »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64