TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: daron on January 06, 2004, 05:28:32 PM

Title: ACAD2000 - 2002 users?
Post by: daron on January 06, 2004, 05:28:32 PM
I have a routine that I wrote using 2004. I sent the file along to a machine using 2002. One of the functions is looking for length and area properties in a nested or non-nested closed polyline. On my machine it finds both and everything's great, but on the 2002 machine it acts like a polyline doesn't have a length. I assume on any version there should be a length property to a pline. Here is the code, can any 2002 users replicate this problem:
Code: [Select]
(defun len-area (/ vl-obj)
     (cond ((setq nent (nentsel "\nSelect Object to check "))
   (setq vl-obj (vlax-ename->vla-object (car nent)))
   (cond ((and (= (vlax-curve-getEndParam vl-obj) 1.0)
(vlax-property-available-p vl-obj 'length)
  )
  (setq pipe-len (vla-get-length vl-obj)
len-ft  (strcat (rtos (/ pipe-len 12) 2 0)
 "'"
 )
  )
 )
 ((> (vlax-curve-getEndParam vl-obj) 1.0)
  (if (vlax-property-available-p vl-obj 'length)
(setq pipe-len (vla-get-length vl-obj)
     len-ft   (strcat (rtos (/ pipe-len 12) 2 0)
      "'"
      )
)
  )
  (if (vlax-property-available-p vl-obj 'area)
(setq pipe-area (vla-get-area vl-obj)
     area-ft (strcat (rtos (/ pipe-area 144) 2 0)
"'"
)
)
  )
 )
   )
  )
     )
)

Yes, I wrote this the day I read Stig's tutorial on curve's. Who knew I'd need it so quick.

Sorry, the other code was not tested right. This one should do better.
Title: ACAD2000 - 2002 users?
Post by: Kerry on January 06, 2004, 06:48:45 PM
Yes

AcadLWPolyline AcadPolyline have a length property that was not available in versions of the Object Model prior to AC2004 .. so VBA is affected too.

kwb
Title: ACAD2000 - 2002 users?
Post by: SMadsen on January 07, 2004, 04:33:20 AM
Daron, how come you don't use vlax-curve-getdistatparam to get the length? That'll work in 2000 and after.
Title: ACAD2000 - 2002 users?
Post by: daron on January 07, 2004, 09:37:55 AM
Did you explain that one? I'm too new with those. They suited the purpose I saw them for, but if the getdistatparam is my workaround, then I'll use it. Thanks for the thought. Kerry, thanks for letting me know that nothing was wrong with the other machines.
Title: ACAD2000 - 2002 users?
Post by: SMadsen on January 07, 2004, 10:32:34 AM
Watch out for the follow-up in relaxed-curves (http://theswamp.org/phpBB2/viewtopic.php?t=467)  :)

Hopefully posting it this evening
Title: ACAD2000 - 2002 users?
Post by: daron on January 07, 2004, 10:33:18 AM
Well, here is the end-result. Thanks Stig.
Code: [Select]
;;;arguments = any string element i.e. "'".
(defun len-area (str-callout / vl-obj)
     (cond ((setq nent (nentsel "\nSelect Object to check "))
   (setq vl-obj      (vlax-ename->vla-object (car nent))
 int-pts     (vlax-curve-getEndParam vl-obj)
 bool-closed (vlax-curve-IsClosed vl-obj)
 pipe-len    (vlax-curve-getDistAtParam vl-obj int-pts)
 len-ft      (strcat (rtos (/ pipe-len 12) 2 0)
     str-callout
     )
   )
   (cond (bool-closed
  (setq pipe-area (vlax-curve-GetArea vl-obj)
area-ft   (strcat (rtos (/ pipe-area 144) 2 0)
  str-callout
  )
  )
 )
   )
  )
     )
)
Title: ACAD2000 - 2002 users?
Post by: daron on January 07, 2004, 10:44:20 AM
OBTW, I am looking forward to the next installment. In the mean time:
(http://theswamp.org/swamp.files/Public/GreenGator4.gif)
Title: ACAD2000 - 2002 users?
Post by: Dent Cermak on January 07, 2004, 01:07:03 PM
I HAVE DEVELOPED A NEW RATING SYSTEM THAT IS MORE ACCURATE.
I RATE THIS ONE AS:





(http://theswamp.org/lilly.pond/Dent/busterOval.jpg)





This icon comes with the AutoCad Electrical pac. It's the "Laying Cable" command.