Author Topic: Civil 3D Structure Position  (Read 9087 times)

0 Members and 1 Guest are viewing this topic.

jmcshane

  • Newt
  • Posts: 83
Civil 3D Structure Position
« on: June 19, 2013, 07:33:37 AM »
Hi,
This might sound like a silly question, but how do I find the insertion point of a civil 3d Structure.
Code: [Select]
(if (> (setq SelectionSet (ssget "X" (list(cons 0 "AECC_STRUCTURE")))) Nil)
(progn
  (setq Objectctr 0)
(repeat (sslength SelectionSet)
(setq Item (ssname SelectionSet Objectctr))
(setq Item (vlax-ename->vla-object Item))
  (setq StructureName (vla-get-name Item))
  (setq StructurePos (vla-get-position Item))
  (setq Objectctr (1+ Objectctr))
)
)
  )
How do I extract the xyz from this line!
Code: [Select]
(setq StructurePos (vla-get-position Item))
Sorry if its obvious, I can't see the wood from the trees here!

Cheers

John
John.

Civil 3D 2021. Windows 10

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Civil 3D Structure Position
« Reply #1 on: June 19, 2013, 09:36:56 AM »
Just a stab in the dark .. but maybe ..


Code: [Select]
(setq StructurePos (vlax-get Item 'position))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Civil 3D Structure Position
« Reply #2 on: June 19, 2013, 09:39:36 AM »
I would guess InsertionPoint  8)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

jmcshane

  • Newt
  • Posts: 83
Re: Civil 3D Structure Position
« Reply #3 on: June 19, 2013, 09:53:23 AM »
Hi Ronjonp,

Your code gives me this line.
Code: [Select]
#<VLA-OBJECT IAeccPoint3d 000000005d92b4d0>
And when I inspect it using the vlide editor it shows me the x y z coordinates but I cant seem to "catch" them.


CAB,
I have tried that as well but it doesn't recognize insertionpoint.

John
I am wondering if it is available at all seeing as it is a civil 3d object! :-(
Thanks for the replies.
John.

Civil 3D 2021. Windows 10

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Civil 3D Structure Position
« Reply #4 on: June 19, 2013, 10:12:44 AM »
Maybe?


Code: [Select]
(list (vlax-get structurepos 'x) (vlax-get structurepos 'y) (vlax-get structurepos 'z))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jmcshane

  • Newt
  • Posts: 83
Re: Civil 3D Structure Position
« Reply #5 on: June 19, 2013, 10:22:08 AM »
Bingo! :-)
Thanks Ronjonp.
John.

Civil 3D 2021. Windows 10

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Civil 3D Structure Position
« Reply #6 on: June 19, 2013, 10:23:58 AM »
In otherwords, the X Y and Z are properties of the IAeccPoint3D object.  They can be accessed via the property functions such as (vlax-get...) and (vlax-get-property...).  This can be applied to virtually any object.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

jmcshane

  • Newt
  • Posts: 83
Re: Civil 3D Structure Position
« Reply #7 on: June 19, 2013, 10:45:11 AM »
Thanks dgorsman, so much to learn....so little time!!
But that is definitely something I will be looking in to.
John.

Civil 3D 2021. Windows 10

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Civil 3D Structure Position
« Reply #8 on: June 19, 2013, 10:49:59 AM »
Bingo! :-)
Thanks Ronjonp.


Happy to help :).


This would probably work too:


Code: [Select]
(list (vla-get-x structurepos) (vla-get-y structurepos) (vla-get-z structurepos))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Civil 3D Structure Position
« Reply #9 on: June 19, 2013, 01:11:32 PM »
Cool!


Code: [Select]
(defun _structurePosition (structure / p)
  (setq p (vlax-get structure 'Position))
  (mapcar 'vlax-get (list p p p) '(x y z))
)

Code: [Select]
(defun _pipeStartEndStructurePosition (pipe / lst)
  (if (vl-remove nil
                 (setq lst (mapcar
                             (function
                               (lambda (structure / s p)
                                 (if (and (setq s (vlax-get pipe structure))
                                          (setq p (vlax-get s 'Position))
                                     )
                                   (mapcar 'vlax-get (list p p p) '(x y z))
                                 )
                               )
                             )
                             '(StartStructure EndStructure)
                           )
                 )
      )
    lst
  )
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

jmcshane

  • Newt
  • Posts: 83
Re: Civil 3D Structure Position
« Reply #10 on: June 20, 2013, 06:12:27 AM »
 :-o

Alan, you are confusing me! :-)
I am so out of practice!
How would I use this?


John

John.

Civil 3D 2021. Windows 10

jmcshane

  • Newt
  • Posts: 83
Re: Civil 3D Structure Position
« Reply #11 on: June 20, 2013, 08:01:07 AM »
Just before I break something here, Can someone please enlighten me as to why this line doesn't select text at the given coordinate?

Code: [Select]
(setq TextSel
(ssget "X"
(list (0 . "TEXT")
      (cons 10
    (list (vlax-get structurepos 'x)
  (vlax-get structurepos 'y)
    )
      )
)
)
  )
I have spend all morning on this and time has run out to get this routine finished.  :-(
Any help would be appreciated.
John
John.

Civil 3D 2021. Windows 10

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Civil 3D Structure Position
« Reply #12 on: June 20, 2013, 08:14:27 AM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (setq TextSel
  2.     (ssget "_X"
  3.         (list '(0 . "TEXT")
  4.             (list 10 (vlax-get structurepos 'x) (vlax-get structurepos 'y) 0.0)
  5.         )
  6.     )
  7. )

PS: Please avoid using tabs in code, they are annoying  :-P

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Civil 3D Structure Position
« Reply #13 on: June 20, 2013, 08:20:35 AM »
Code: [Select]
(defun _pipeStartEndStructurePosition (pipe / lst)
...
)

Nice code, but no need for the if statement:
Code - Auto/Visual Lisp: [Select]
  1. (defun _pipestartendstructureposition ( obj )
  2.     (vl-remove nil
  3.         (mapcar
  4.             (function
  5.                 (lambda ( prop / str pos )
  6.                     (if
  7.                         (and
  8.                             (setq str (vlax-get obj prop))
  9.                             (setq pos (vlax-get str 'position))
  10.                         )
  11.                         (mapcar '(lambda ( p ) (vlax-get pos p)) '(x y z))
  12.                     )
  13.                 )
  14.             )
  15.            '(startstructure endstructure)
  16.         )
  17.     )
  18. )

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Civil 3D Structure Position
« Reply #14 on: June 20, 2013, 08:27:42 AM »
Code: [Select]
(defun _pipeStartEndStructurePosition (pipe / lst)
...
)

Nice code, but no need for the if statement:
Code - Auto/Visual Lisp: [Select]
  1. (defun _pipestartendstructureposition ( obj )
  2.     (vl-remove nil
  3.         (mapcar
  4.             (function
  5.                 (lambda ( prop / str pos )
  6.                     (if
  7.                         (and
  8.                             (setq str (vlax-get obj prop))
  9.                             (setq pos (vlax-get str 'position))
  10.                         )
  11.                         (mapcar '(lambda ( p ) (vlax-get pos p)) '(x y z))
  12.                     )
  13.                 )
  14.             )
  15.            '(startstructure endstructure)
  16.         )
  17.     )
  18. )
If you notice, the vl-remove nil was only a check, I don't store it. I want it to return a nil value for the start/end structure. That way, I know which one is missing and which is there.
eg.
(nil <point>) => no start, only end
(<point nil)   => no end, only start
nil                 => a pipe without a structure.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox