Author Topic: Civil 3D Feature Line Getpoints method  (Read 7829 times)

0 Members and 1 Guest are viewing this topic.

Ajilal

  • Mosquito
  • Posts: 12
Civil 3D Feature Line Getpoints method
« on: August 07, 2012, 09:32:50 AM »
Hi,

I am trying to get the Points collection from the Civil3d feature line.
The featureline have a method Getpoints(1).

The below lisp code giving me an error on this  line -> (vlax-invoke-method FLE 'GetPoints FLE)
error: lisp value has no coercion to VARIANT with this type:  #<VLA-OBJECT IAeccLandFeatureLine 0000000028537610>

Code:
------------------
(vl-load-com)
(defun c:FLBL ( / FLE acadOBject acadDocument mSpace)
(setq acadOBject (vlax-get-acad-object))
(setq acadDocument (vlax-get-property acadObject 'ActiveDocument))
(setq mSpace (vlax-get-property acadDocument 'Modelspace))
(setq FLE (car (entsel "\nSelect the featureline: ")))
(setq FLE (vlax-ename->vla-object FLE))
(vlax-dump-object FLE T)

(vlax-invoke-method FLE 'GetPoints FLE)

);defun
-----------------------------------------------------------

I am using Civil3D 2012.


Thanks
AJIL

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Feature Line Getpoints method
« Reply #1 on: August 07, 2012, 09:45:06 AM »
First, welcome to TheSwamp!

Consider this example:

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:FOO (/ ss)
  3.   (princ "\rSelect a feature line to return points: ")
  4.   (princ
  5.     (if (setq ss (ssget ":S:E" '((0 . "AECC_FEATURE_LINE"))))
  6.       (vlax-invoke
  7.         (vlax-ename->vla-object (ssname ss 0))
  8.         'getpoints
  9.       )
  10.       "\n** Nothing selected ** "
  11.     )
  12.   )
  13.   (princ)
  14. )
  15.  
"How we think determines what we do, and what we do determines what we get."

Ajilal

  • Mosquito
  • Posts: 12
Re: Civil 3D Feature Line Getpoints method
« Reply #2 on: August 07, 2012, 10:06:31 AM »
Hi
First, welcome to TheSwamp!

Consider this example:

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:FOO (/ ss)
  3.   (princ "\rSelect a feature line to return points: ")
  4.   (princ
  5.     (if (setq ss (ssget ":S:E" '((0 . "AECC_FEATURE_LINE"))))
  6.       (vlax-invoke
  7.         (vlax-ename->vla-object (ssname ss 0))
  8.         'getpoints
  9.       )
  10.       "\n** Nothing selected ** "
  11.     )
  12.   )
  13.   (princ)
  14. )
  15.  

Thanks!!!!!!!!!!!!!!.............It works.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Feature Line Getpoints method
« Reply #3 on: August 07, 2012, 10:07:31 AM »

Thanks!!!!!!!!!!!!!!.............It works.

You're welcome; I'm happy to help.  :-)
"How we think determines what we do, and what we do determines what we get."

Ajilal

  • Mosquito
  • Posts: 12
Re: Civil 3D Feature Line Getpoints method
« Reply #4 on: August 07, 2012, 10:13:05 AM »
Hi again,

But 2 doubts......

1) So Vlax-invoke should use instead of Vlax-invoke-method in future ?
whats the main difference with these two ?
I found the topic for vlax-invoke-method http://www.theswamp.org/~john/avlisp/#vlax-invoke-method
But not for vlax-invoke

2)How can I paste the code like you did ?.............


Thanks again.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Feature Line Getpoints method
« Reply #5 on: August 07, 2012, 10:16:50 AM »
1) So Vlax-invoke should use instead of Vlax-invoke-method in future ?
whats the main difference with these two ?
I found the topic for vlax-invoke-method http://www.theswamp.org/~john/avlisp/#vlax-invoke-method
But not for vlax-invoke

Both vlax-invoke, and vlax-invoke-method will work, similar to using vlax-get instead of vlax-get-property. I'm not sure of the history, but I believe one stems from Vital LISP. Use what you're more comfortable with.

2)How can I paste the code like you did ?.............

To use [CODE ] Tags, look in the upper right when drafting your post to see the "Code" drop down menu, and select the code language you are posting. There may be a tutorial for this on the site somewhere; if I find it, I'll post it here.
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Civil 3D Feature Line Getpoints method
« Reply #6 on: August 07, 2012, 10:17:57 AM »
Looks like this is a case of the docs not being very clear (What? How'd THAT happen?? :-) ). The docs, and the information returned by vlax-dump-object, infer that an argument is needed for the getpoints method. As RenderMan shows, this is not the case since his example does return all of the points on the featureline...both the PI's and Elevation points. What the docs infer is that you must specify which one you want, PI's or Elevations, by providing the appropriate Enum: aeccLandFeatureLinePointPI (1) or aeccLandFeatureLinePointElevation (2). So if you want just one or the other:
Code - Lisp: [Select]
  1. (vl-load-com)
  2.  
  3. (defun c:FOO_PIs(/ ss)
  4.   (princ "\rSelect a feature line to return points: ")
  5.   (princ
  6.     (if (setq ss (ssget ":S:E" '((0 . "AECC_FEATURE_LINE"))))
  7.       (vlax-invoke
  8.         (vlax-ename->vla-object (ssname ss 0))
  9.         'getpoints
  10.         1
  11.       )
  12.       "\n** Nothing selected ** "
  13.     )
  14.   )
  15.   (princ)
  16. )
  17.  
  18. (defun c:FOO_Elevs (/ ss)
  19.   (princ "\rSelect a feature line to return points: ")
  20.   (princ
  21.     (if (setq ss (ssget ":S:E" '((0 . "AECC_FEATURE_LINE"))))
  22.       (vlax-invoke
  23.         (vlax-ename->vla-object (ssname ss 0))
  24.         'getpoints
  25.         2
  26.       )
  27.       "\n** Nothing selected ** "
  28.     )
  29.   )
  30.   (princ)
  31. )
  32.  

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Civil 3D Feature Line Getpoints method
« Reply #7 on: August 07, 2012, 10:18:39 AM »
The vlax-invoke is an undocumented function, and as RM's alluded to comes from the original Vital-Lisp (the origin on Visual Lisp). Its main difference from vlax-invoke-method is that it "automatically" converts to and from lisp<->com data types (or at least tries to).

E.g. sending a point list (X Y Z) to a com-method would need a safearray if you use vlax-invoke-method, but with vlax-invoke you can send the normal lisp point-list directly.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Feature Line Getpoints method
« Reply #8 on: August 07, 2012, 10:40:23 AM »
Looks like this is a case of the docs not being very clear (What? How'd THAT happen?? :-) ).

 :lmao:

The docs, and the information returned by vlax-dump-object, infer that an argument is needed for the getpoints method.

... Missed that.  :lol:

As RenderMan shows, this is not the case since his example does return all of the points on the featureline...both the PI's and Elevation points. What the docs infer is that you must specify which one you want, PI's or Elevations, by providing the appropriate Enum: aeccLandFeatureLinePointPI (1) or aeccLandFeatureLinePointElevation (2). So if you want just one or the other:

I'm not getting any result for the latter of your examples (FOO_ELEVS), and appear to be getting the same result for no enum vs. enum = 1 (FOO_PIS):

Code - Auto/Visual Lisp: [Select]
  1. Command: foo
  2. Select a feature line to return points:
  3. Select objects:
  4. (12525.1 15084.4 0.0 12525.1 16967.8 18.8343)
  5.  
  6. Command: foo_pis
  7. Select a feature line to return points:
  8. Select objects:
  9. (12525.1 15084.4 0.0 12525.1 16967.8 18.8343)
  10.  
  11. Command: foo_elevs
  12. Select a feature line to return points:
  13. Select objects:
  14. nil
  15.  
  16.  
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Civil 3D Feature Line Getpoints method
« Reply #9 on: August 07, 2012, 11:20:28 AM »
Does the F/L have Elevation Points set along it?


Command: FOO
Select a feature line to return points:
Select objects:
(-343.085 4959.28 2.0 505.0 5539.82 40.0 1400.16 6152.58 86.5022 2662.31
5383.13 50.0 3788.18 4696.75 170.406)

Command:
Command: FOO_PIS
Select a feature line to return points:
Select objects:
(-343.085 4959.28 2.0 1400.16 6152.58 86.5022 3788.18 4696.75 170.406)

Command:
Command: FOO_ELEVS
Select a feature line to return points:
Select objects:
(505.0 5539.82 40.0 2662.31 5383.13 50.0)

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Feature Line Getpoints method
« Reply #10 on: August 07, 2012, 11:30:04 AM »
Does the F/L have Elevation Points set along it?

Start & end only... 0.0000 and 18.8343 respectively, as shown in the code block above.

Perhaps I misunderstood what bit-code 2 does... does it only return elevations other than start and end (excluding my 2 point Feature Line)?
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Civil 3D Feature Line Getpoints method
« Reply #11 on: August 07, 2012, 11:45:12 AM »
You can set non-pi elevation points on featurelines. The 2 returns just the intermediate elevation points between PI's.

Ajilal

  • Mosquito
  • Posts: 12
Re: Civil 3D Feature Line Getpoints method
« Reply #12 on: August 07, 2012, 01:21:24 PM »
Code - Auto/Visual Lisp: [Select]
  1. (Now I learned more things than what I was looking for)
  2. (Thanks RenderMan)
  3. (Thanks Jeff_M)
  4. (Thanks irneb)
  5. (also
  6. (Its good to be in Swamp)
  7. )
  8.  

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Civil 3D Feature Line Getpoints method
« Reply #13 on: February 14, 2013, 01:07:42 AM »
Useful. Thank you!

First, welcome to TheSwamp!

Consider this example:

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:FOO (/ ss)
  3.   (princ "\rSelect a feature line to return points: ")
  4.   (princ
  5.     (if (setq ss (ssget ":S:E" '((0 . "AECC_FEATURE_LINE"))))
  6.       (vlax-invoke
  7.         (vlax-ename->vla-object (ssname ss 0))
  8.         'getpoints
  9.       )
  10.       "\n** Nothing selected ** "
  11.     )
  12.   )
  13.   (princ)
  14. )
  15.  

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Feature Line Getpoints method
« Reply #14 on: February 14, 2013, 10:51:34 AM »
Useful. Thank you!

You're welcome; I'm happy to help.
"How we think determines what we do, and what we do determines what we get."