(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!(setq StructurePos (vla-get-position Item))
(setq StructurePos (vlax-get Item 'position))
#<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.(list (vlax-get structurepos 'x) (vlax-get structurepos 'y) (vlax-get structurepos 'z))
Bingo! :-)
Thanks Ronjonp.
(list (vla-get-x structurepos) (vla-get-y structurepos) (vla-get-z structurepos))
(defun _structurePosition (structure / p)
(setq p (vlax-get structure 'Position))
(mapcar 'vlax-get (list p p p) '(x y z))
)
(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
)
)
(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. :-(Code: [Select](defun _pipeStartEndStructurePosition (pipe / lst)
...
)
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.Code: [Select](defun _pipeStartEndStructurePosition (pipe / lst)
...
)
Nice code, but no need for the if statement:Code - Auto/Visual Lisp: [Select]
:-oThe first can be applied to a vla-object for a structure and it will return the position. The second can be applied to a vla-object pipe and it will return the positions of the start and end (if any) structures.
Alan, you are confusing me! :-)
I am so out of practice!
How would I use this?
John
(_structurePosition <vla-object>)
(_pipeStartEndStructurePosition <vla-object>)
(defun _pipeStartEndStructurePosition (pipe / lst)
(if (vl-some 'and
(setq lst (mapcar
(function
(lambda (structure / s p)
(if (setq s (vlax-get pipe structure))
(mapcar 'vlax-get (list (setq p (vlax-get s 'Position)) p p) '(x y z))
)
)
)
'(StartStructure EndStructure)
)
)
)
lst
)
)
PS: Please avoid using tabs in code, they are annoying :-PI hear you, but I have just got 2014 and haven't had time to set things up properly.
Thanks Lee, but this is still not working!Code: [Select](setq TextSel
(ssget "_X"
(list '(0 . "TEXT")
(list 10 (vlax-get structurepos 'x) (vlax-get structurepos 'y) 0.0)
)
)
)
(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 StructureIns
(list (vlax-get structurepos 'x)
(vlax-get structurepos 'y)
(vlax-get structurepos 'z)
)
)
(progn
(setq TextSel (ssget "_X"
(list '(0 . "TEXT")
(list 10
(vlax-get structurepos 'x)
(vlax-get structurepos 'y)
0.0
)
)
)
)
(if TextSel
(repeat (setq Ctr (sslength TextSel))
(setq Ctr (1- Ctr))
(setq TextItem (ssname TextSel Ctr))
(setq TextItem (vlax-ename->vla-object TextItem))
(if (= (vlax-safearray->list
(vlax-variant-value
(vla-get-insertionpoint TextItem)
)
)
(list (car StructureIns) (cadr StructureIns) 0.0)
)
(setq TextString (vla-get-TextString TextItem))
)
)
)
)
(vla-put-name Item TextString)
(setq Objectctr (1+ Objectctr))
)
)
)
Why don't you just use a structure label that only displays the name? Wouldn't that be easier, or am I missing something?PS: Please avoid using tabs in code, they are annoying :-PI hear you, but I have just got 2014 and haven't had time to set things up properly.QuoteThanks Lee, but this is still not working!Code: [Select](setq TextSel
(ssget "_X"
(list '(0 . "TEXT")
(list 10 (vlax-get structurepos 'x) (vlax-get structurepos 'y) 0.0)
)
)
)
Here is the deal....
I have a civil 3d Model, I also have a piece of text at the insertion of each Structure which needs to become the structure name.........
I am trying to catch each piece of text at each Structure insertion point and rename the structure.
My code: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 StructureIns
(list (vlax-get structurepos 'x)
(vlax-get structurepos 'y)
(vlax-get structurepos 'z)
)
)
(progn
(setq TextSel (ssget "_X"
(list '(0 . "TEXT")
(list 10
(vlax-get structurepos 'x)
(vlax-get structurepos 'y)
0.0
)
)
)
)
(if TextSel
(repeat (setq Ctr (sslength TextSel))
(setq Ctr (1- Ctr))
(setq TextItem (ssname TextSel Ctr))
(setq TextItem (vlax-ename->vla-object TextItem))
(if (= (vlax-safearray->list
(vlax-variant-value
(vla-get-insertionpoint TextItem)
)
)
(list (car StructureIns) (cadr StructureIns) 0.0)
)
(setq TextString (vla-get-TextString TextItem))
)
)
)
)
(vla-put-name Item TextString)
(setq Objectctr (1+ Objectctr))
)
)
)
Can anyone help?
Thanks in advance.
John
Thanks Lee,I wonder if you could have used ssget crossing from the structure's bounding box.
Tolerance................ Something I am short off, but what the code needed!!!
Turns out, the text was not exactly on the insert of the structure.
Alan,
That is all we use as well!
Thanks for all your help guys.
John
That is a good idea Alan, even with Lee's code I still had a fair bit of manual cleaning to do as it didn't catch all the text. Then there was the issue of duplicate numbers. ( its a complicated system!!)Sounds like you have your work cut out for you. Good luck. :)
Unfortunately I am going to have to leave it until I have to do it again or until I get free time, as I now have to rename all the associated alignments!! :-)
Thanks for your help.
John