Calculate area in % Meter Square for Object inside Flexible Routing

Calculate area in % Meter Square for Object inside Flexible Routing

ndnam7693
Contributor Contributor
1,283 Views
13 Replies
Message 1 of 14

Calculate area in % Meter Square for Object inside Flexible Routing

ndnam7693
Contributor
Contributor

Hello Everyone, 

I'm ME Engineer. Now I'm draw shop drawing for Underground Pipe for Electric Incoming System. Electric Cable inside  HDPE Flexible Pipe. But Consulting Team of Client requested me that they want to indicated % Meter Square for Object inside Flexible Routing. Help me! Thanks.

 

example.PNG

TFP size.PNGCable Size.PNG

0 Likes
Accepted solutions (1)
1,284 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant

It's hard to say in which units you're in, so adjust the measurement.

 

(vl-load-com)

(defun c:LabelAreaPerc ( / dst anf obj sel obj aro ari pnt)
  
  (and (setq dst 1.00
             ang 1.57)
       (setq sel (nentsel "\nSelect outer circle: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq aro (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.MLEADER"
                "_none" (setq pnt (vlax-curve-getclosestpointto obj (cadr sel)))
                "_none" (polar pnt ang dst)
                (strcat (rtos aro 2 1) "m2"))
       (setq sel (nentsel "\nSelect inner circle: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq ari (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.MLEADER"
                "_none" (setq pnt (vlax-curve-getclosestpointto obj (cadr sel)))
                "_none" (polar pnt ang dst)
                (strcat (rtos ari 2 1) "m2 - " (rtos (* 100 (/ ari aro)) 2 0) "%")))
  (princ)
  )
0 Likes
Message 3 of 14

ndnam7693
Contributor
Contributor

Firstly, Thank for help. But I've some problem when using your lisp. Please see at attach pics. Dimension show at ucs (0,0,0). Almost, I create block and change base point to center of Object then I dimension and it's working but show wrong position. Other one I don't change base point, Your lisp working smoothly. Help me If you can resolve.

 

Test.PNG

0 Likes
Message 4 of 14

ВeekeeCZ
Consultant
Consultant

Sure, no trouble. 

 

(vl-load-com)

(defun c:LabelAreaPerc ( / dst ang obj sel obj aro ari pnt)
  
  (and (setq dst 1.00
             ang 0.79)
       (setq sel (nentsel "\nSelect outer circle: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq aro (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.MLEADER"
                "_none" (setq pnt (trans (vlax-curve-getclosestpointto obj (trans (cadr sel) 1 0)) 0 1))
                "_none" (polar pnt ang dst)
                (strcat (rtos aro 2 1) "m2"))
       (setq sel (nentsel "\nSelect inner circle: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq ari (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.MLEADER"
                "_none" (setq pnt (trans (vlax-curve-getclosestpointto obj (trans (cadr sel) 1 0)) 0 1))
                "_none" (polar pnt ang dst)
                (strcat (rtos ari 2 1) "m2 - " (rtos (* 100 (/ ari aro)) 2 0) "%")))
  (princ)
  )
0 Likes
Message 5 of 14

ndnam7693
Contributor
Contributor

Sorry, but I cannot dimension with right position. :(. Plz check my file, maybe you can get some idea for resolve.

0 Likes
Message 6 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

Now you see how important is always post a test dwg.

 

(vl-load-com)

(defun c:LabelAreaPerc ( / dst ang obj sel obj aro ari pnt)
  
  (and (setq dst 10.00
             ang 0.79)
       (setq sel (nentsel "\nSelect outer circle: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq aro (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.MLEADER"
                "_none" (setq pnt (osnap (cadr sel) "_nea"))
                "_none" (polar pnt ang dst)
                (strcat (rtos aro 2 1) "m2"))
       (setq sel (nentsel "\nSelect inner circle: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq ari (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.MLEADER"
                "_none" (setq pnt (osnap (cadr sel) "_nea"))
                "_none" (polar pnt ang dst)
                (strcat (rtos ari 2 1) "m2 - " (rtos (* 100 (/ ari aro)) 2 0) "%")))
  (princ)
  )
Message 7 of 14

ndnam7693
Contributor
Contributor

Thank bro, It's work perfect. Many thanks to you. 

0 Likes
Message 8 of 14

k_ngo-quoc
Enthusiast
Enthusiast

Hi,

Your lisp is perfect! I usually work with mm. Is it possible to transform the area in m² and the mleader as "TEST" style.

Thanks advance.

My file in attach.

 

0 Likes
Message 9 of 14

ВeekeeCZ
Consultant
Consultant

Here you go. Only thing is that you should adjust your Test DimStyle, its Text / Vertical Text Placement to Above.

 

(vl-load-com)

(defun c:LeaderArea ( / dst ang obj sel obj aro ari pnt)
  
  (and (setq dst 1500.00
             ang 0.79)
       (vl-cmdf "_.-DIMSTYLE" "_Restore" "Test")
       (setq sel (nentsel "\nSelect object: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq aro (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.LEADER"
                "_none" (setq pnt (osnap (cadr sel) "_nea"))
                "_none" (polar pnt ang dst)
                "_none" "@550,0"
                ""
                (strcat (rtos (/ aro 1000000) 2 1) "m2")
                "")
       )
  (princ)
  )
0 Likes
Message 10 of 14

Anonymous
Not applicable

Can you adjust a little bit for suite ?. When I pick select 1 outlet circle and then pick 1 inner. But it so spend time when i need pick many inner inside 1 outlet circle. I wanna pick 1 outlet circle and many inner circle?. Thanks

0 Likes
Message 11 of 14

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

Can you adjust a little bit for suite ?. When I pick select 1 outlet circle and then pick 1 inner. But it so spend time when i need pick many inner inside 1 outlet circle. I wanna pick 1 outlet circle and many inner circle?. Thanks


 

Gee... how many of you are up there? 

(vl-load-com)

(defun c:LabelAreaPercM ( / dst ang obj sel obj aro ari pnt)
  
  (and (setq dst 10.00
             ang 0.79)
       (setq sel (nentsel "\nSelect outer circle: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq aro (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.MLEADER"
                "_none" (setq pnt (osnap (cadr sel) "_nea"))
                "_none" (polar pnt ang dst)
                (strcat (rtos aro 2 1) "m2"))
       (while (setq sel (nentsel "\nSelect inner circle: "))
         (and (setq obj (vlax-ename->vla-object (car sel)))
              (or (not (vl-catch-all-error-p (setq ari (vl-catch-all-apply 'vla-get-area (list obj)))))
                  (prompt "\nWrong selection. Area property is not available!"))
              (vl-cmdf "_.MLEADER"
                       "_none" (setq pnt (osnap (cadr sel) "_nea"))
                       "_none" (polar pnt ang dst)
                       (strcat (rtos ari 2 1) "m2 - " (rtos (* 100 (/ ari aro)) 2 0) "%")))))
  (princ)
  )
0 Likes
Message 12 of 14

k_ngo-quoc
Enthusiast
Enthusiast

Thanks for transforming in m². But it missed the second click (%).

Thanks in advance for your help.

0 Likes
Message 13 of 14

ВeekeeCZ
Consultant
Consultant

@k_ngo-quoc wrote:

Thanks for transforming in m². But it missed the second click (%).

Thanks in advance for your help.


 

Sorry about that, misunderstanding. I got it back.

 

; **** LEADER VERSION ****   ; + CONVERSION MM TO M

(vl-load-com)

(defun c:LabelAreaPercM ( / dst ang obj sel obj aro ari pnt)
  
  (and (setq dst 1500.00
             ang 0.79)
       (vl-cmdf "_.-DIMSTYLE" "_Restore" "Test")
       (setq sel (nentsel "\nSelect outer area: "))
       (setq obj (vlax-ename->vla-object (car sel)))
       (or (not (vl-catch-all-error-p (setq aro (vl-catch-all-apply 'vla-get-area (list obj)))))
           (prompt "\nWrong selection. Area property is not available!"))
       (vl-cmdf "_.LEADER"
                "_none" (setq pnt (osnap (cadr sel) "_nea"))
                "_none" (polar pnt ang dst)
                "_none" "@550,0"
                ""
                (strcat (rtos (/ aro 1000000) 2 1) "m2")
                "")
       (while (setq sel (nentsel "\nSelect inner area: "))
         (and (setq obj (vlax-ename->vla-object (car sel)))
              (or (not (vl-catch-all-error-p (setq ari (vl-catch-all-apply 'vla-get-area (list obj)))))
                  (prompt "\nWrong selection. Area property is not available!"))
              (vl-cmdf "_.LEADER"
                       "_none" (setq pnt (osnap (cadr sel) "_nea"))
                       "_none" (polar pnt ang dst)
                       "_none" "@550,0"
                       ""
                       (strcat (rtos (/ ari 1000000) 2 1) "m2 - " (rtos (* 100 (/ ari aro)) 2 0) "%")
                       ""))))
  (princ)
  )
0 Likes
Message 14 of 14

k_ngo-quoc
Enthusiast
Enthusiast

Perfect! Thanks!

0 Likes