Help with an error trap.

Help with an error trap.

tcorey
Mentor Mentor
478 Views
2 Replies
Message 1 of 3

Help with an error trap.

tcorey
Mentor
Mentor

My goal is to find a way to differentiate whether a parcel loop item is a line or an arc.

 

If I dump the object, I get either IAeccParcelSegmentCurve or IAeccParcelSegmentLine. I can't find a way to get that value into a variable.

 

So, I thought it would be simple. If the object is a curve, it has a radius. I ask the object (setq rad (vlax-get seg 'Radius)) 

 

That works fine when the object is a curve. If it's a line, it gives an error, which I expect it to do. What I would like to do is (setq rad nil) if the original setq rad throws an error. 

 

I am struggling. 

 

Thanks in advance.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Accepted solutions (1)
479 Views
2 Replies
Replies (2)
Message 2 of 3

Jeff_M
Consultant
Consultant
Accepted solution

Tim, check if the property is available like so:

 

(vlax-for loop loops
  (vlax-for segment loop
    (if (vlax-property-available-p segment 'radius)
      (princ "\nSegment is an arc.") ;;do what you want with the arc segment here
      (princ "\nSegment is a line.")  ;;do what you want with the line segment here
     ) 
    )
   )

In a short test of a Parcel with 4 lines and an arc, this is the result:

 

Segment is a line.
Segment is a line.
Segment is a line.
Segment is an arc.
Segment is a line.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 3

tcorey
Mentor
Mentor

Thanks, Jeff!



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes