Hi,
I want to select surfaces by name, add them it into selection set and change there layers to something else. The idea behind is that I want to make a certain draw order in my drawing, but the case is that almost all of the civil objects are created in layer 0, so they are not selectable by layer. So far I managed to select them by type, but I still need to filter out serfaces including the string "DES" in there names and change there layer to known existing layer.
I have the order list and by selection of each object I am arranging the order, but I have surfaces like PRE and DES which needs to be in a different level of the order. Selection of all surfaces doesn't work, I need a specific one.
Below is the code I have by now:
(defun DRO (/ aa bb cc dd ee)
(if (SETQ aa (ssget "x" (list (CONS 0 "AECC_TIN_SURFACE"))))
(command "_.draworder" aa "" "_front"))
(if (SETQ bb (ssget "x" (list (CONS 0 "AECC_SURFACE_CONTOUR_LABEL_GROUP"))))
(command "_.draworder" bb "" "_front"))
(if (SETQ SS (ssget "x" (list (CONS 8 "56-DES"))))
(command "_.draworder" SS "" "_front"))
(if (SETQ cc (ssget "x" (list (CONS 0 "AECC_ALIGNMENT_STATION_LABEL_GROUP"))))
(command "_.draworder" cc "" "_front"))
(if (SETQ dd (ssget "x" (list (CONS 0 "AECC_SAMPLE_LINE"))))
(command "_.draworder" dd "" "_front"))
(if (SETQ ee (ssget "x" (list (CONS 0 "AECC_ALIGNMENT"))))
(command "_.draworder" ee "" "_front"))
(setq check nil)
)
(YesNo "CHECK, CHECK DOUBLE CHECK!!!" "DID YOU PUT THE DESIGN IN LAYER 56-DES?")
(if (= check 1) (DRO) (setq check nil) )
but this is not the most elegant way, because there is alert dieplay asking if all the design surface are moved in the correct layer, if user hit "Yes" the DRO function starts
.
Any ideas will be helpful.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by marko_ribar. Go to Solution.
Solved by hmsilva. Go to Solution.
Hi Ivanov,
perhaps something like this:
(Untested and ensures that PICKFIRSTis set to 1)
(defun DRO ( / ss) (if (not (setq ss (ssget "x" (list '(8 . "0") (CONS 0 "AECC_TIN_SURFACE,AECC_SURFACE_CONTOUR_LABEL_GROUP,56-DES,AECC_ALIGNMENT_STATION_LABEL_GROUP,AECC_SAMPLE_LINE,AECC_ALIGNMENT" ) ) ) ) ) (foreach x '("AECC_TIN_SURFACE" "AECC_SURFACE_CONTOUR_LABEL_GROUP" "56-DES" "AECC_ALIGNMENT_STATION_LABEL_GROUP" "AECC_SAMPLE_LINE" "AECC_ALIGNMENT" ) (if (setq ss (ssget "x" (list (CONS 0 x)))) (command "_.draworder" ss "" "_front") ) ) (progn (sssetfirst nil ss) (prompt "\nYou'll need to set surfaces layer property, to the correct ones, before running this code!!!" ) ) ) (princ) )
Hope that helps
Henrique
1. Using "AECC_*" instead of "AECC_TIN_SURFACE" may work, for those AECC_ layers.
2. For all the desired objects, perhaps some other feature of the entity could be used.
Post the 'entget data of one or two..
@Anonymous wrote:
Hi Henrique,
Tanks for the replay.
I am not sure if I treat correctly your code.
All of the objects which I want to arrange are originally in layer 0. I can select them by type. But all surfaces which includes 56-DES in their names, need to go in different position of the draw order compared to all of the rest surfaces. By now my lisp works if I change the layer of all the des surfaces to DES-56.
That is why I wanted to avoid any manual selection and change before i run the lisp.
Sorry Ivanov,
Hi Henrique,
The selection set (setq aa(ssget "x" (list(CONS 0 "*56-DES*")))) didnt give any results - nill.
Maybe the property 0 after the CONS is not the right one. Actually the selection above didnt give result with any names of surfaces, even if I wrote the full and accurate name.
Thanks,
Chavdar
@Anonymous wrote:
((-1 . <Entity name: 7fffeeaa960>) (0 . "AECC_TIN_SURFACE") (330 . <Entity name: 7ffff7449f0>) (5 . "19423E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (62 . 6) (370 . 35) (100 . "AeccDbEntity") (100 . "AeccDbGeo_aec") (100 . "AeccDbGeo") (100 . "AeccDbSurface") (100 . "AeccDbSurfaceTin"))
That is the result. Tha name 56-des is indeed not there, but I knew that since the beginning.
Chavdar
I didn't... and I did understood that the surface name had 56-DES in it....
Lets start,
all (0 . "AECC_TIN_SURFACE") must have the a layer property 56-DES?
Henrique
Hello again,
So
All the surfaces in my drawing are in layer 0. When I crate them i give them certain names and the layer is 0 as a default. When I select them afterwords in the properties tab is the name I set and the layer is 0. Toolspace says the same. But if i want to selct tnem by name on the way you suggestes the result is nill. All of the surfaces are giving the same property name (0 . "AECC_TIN_SURFACE").
So that is whay I was wondering where this real/ given name is stored and how it can be reached and used for selection filter.
Chavdar
Try
(vlax-dump-object (vlax-ename->vla-object (car (entsel "\nSelect Surface: "))) T)
and post the result
Henrique
One step closer to the solution:
IAeccTinSurface: IAeccTinSurface interface
; Property values:
; Application (RO) = #<VLA-OBJECT IAeccApplication 0000000088efb290>
; Boundaries (RO) = #<VLA-OBJECT IAeccSurfaceBoundaries 000000007d6ad748>
; Breaklines (RO) = #<VLA-OBJECT IAeccSurfaceBreaklines 000000007d69f378>
; ContourLabelGroups (RO) = #<VLA-OBJECT IAeccSurfaceContourLabelGroups 000000007d6add80>
; Contours (RO) = #<VLA-OBJECT IAeccSurfaceContours 000000007d6a7078>
; DefinitionProperties (RO) = #<VLA-OBJECT IAeccTinSurfaceDefinitionProperties 0000000088efb1a0>
; DEMFiles (RO) = #<VLA-OBJECT IAeccSurfaceDEMFiles 000000007d6a6308>
; Description = "Description"
; DisplayName (RO) = "56-DES Area 429-431"
; Document (RO) = #<VLA-OBJECT IAeccDocument 0000000088efb260>
; EntityTransparency = "ByLayer"
; Handle (RO) = "18A3EB"
; HasExtensionDictionary (RO) = 0
; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 00000000957ea028>
; Labels (RO) = #<VLA-OBJECT IAeccSurfaceLabels 000000007d6accf0>
; Layer = "0"
; Linetype = "ByLayer"
; LinetypeScale = 1.0
; Lineweight = -1
; Material = "ByLayer"
; Name = "56-DES Area 429-431"
; ObjectID (RO) = 66
; ObjectID32 (RO) = 66
; ObjectName (RO) = "AeccDbSurfaceTin"
; OutputTriangles (RO) = (552687.0 7.91299e+006 -429.622 552687.0 7.91299e+006 -429.717 ... )
; OwnerID (RO) = 68
; OwnerID32 (RO) = 68
; PlotStyleName = "ByLayer"
; PointFiles (RO) = #<VLA-OBJECT IAeccSurfacePointFiles 000000007d6a4d28>
; PointGroups (RO) = #<VLA-OBJECT IAeccSurfacePointGroups 000000007d6ad928>
; Points (RO) = (552687.0 7.91299e+006 -429.715 552687.0 7.91299e+006 -429.717 ... )
; ShowToolTip = -1
; Statistics (RO) = #<VLA-OBJECT IAeccTinSurfaceStatistics 0000000088efb4a0>
; Style = #<VLA-OBJECT IAeccSurfaceStyle 0000000098187fb0>
; StyleName (RO) = "DES_Border"
; SurfaceAnalysis (RO) = #<VLA-OBJECT IAeccSurfaceAnalysis 0000000088ef8140>
; TrueColor = #<VLA-OBJECT IAcadAcCmColor 00000000957e6120>
; Type (RO) = 2
; Visible = -1
; Methods supported:
; AddPointMultiple (1)
; ArrayPolar (3)
; ArrayRectangular (6)
; Copy ()
; CreateSnapshot ()
; Delete ()
; ExtractBorder (1)
; ExtractContour (4)
; FindElevationAtXY (2)
; GetBoundingBox (2)
; GetExtensionDictionary ()
; GetXData (3)
; Highlight (1)
; IntersectPointWithSurface (2)
; IntersectWith (2)
; IsReferenceObject ()
; IsReferenceStale ()
; IsReferenceSubObject ()
; IsReferenceValid ()
; Mirror (2)
; Mirror3D (3)
; Move (2)
; PasteSurface (1)
; Rebuild ()
; RebuildSnapshot ()
; RemoveSnapshot ()
; Rotate (2)
; Rotate3D (3)
; SampleElevations (4)
; ScaleEntity (2)
; SetXData (2)
; TransformBy (1)
; Update ()
T
I tried to make the proper selection, but I am missing some vlisp knowledge. I believe you will give me a small tip how to do it correct.
Many thanks in advance,
Chavdar
Hi Chavdar,
perhaps something like this:
(vl-load-com) (defun DRO (/ adoc des i layers obj ss) (setq adoc (vla-get-activedocument (vlax-get-acad-object)) layers (vla-get-layers adoc) ) (vlax-for lay layers (if (= "56-DES" (strcase (vla-get-Name lay))) (setq des T) ) ) (if (null des) (progn (setq des (vla-add layers "56-DES")) (vla-put-color des 1);; change to your standard color ) ) (if (setq ss (ssget "x" (list (CONS 0 "AECC_TIN_SURFACE")))) (progn (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vla-put-Layer obj "56-DES") ) (command "_.draworder" ss "" "_front") ) ) (foreach x '((0 "AECC_SURFACE_CONTOUR_LABEL_GROUP") (8 "56-DES") (0 "AECC_ALIGNMENT_STATION_LABEL_GROUP") (0 "AECC_SAMPLE_LINE" "AECC_ALIGNMENT") ) (if (setq ss (ssget "x" (list (cons (car x) (cadr x))))) (command "_.draworder" ss "" "_front") ) ) (princ) )
(untested, I don't have AutoCAD in this laptop...)
Hope that helps
Henrique
Maybe this...
(defun c:DRO ( / ss el s ) (vl-load-com) (ssget "_X" '((0 . "AECC_TIN_SURFACE"))) (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for e ss (if (wcmatch (vla-get-name e) "56-DES*") (setq el (cons (vlax-vla-object->ename e) el)) ) ) (setq s (ssadd)) (foreach e el (ssadd e s) ) (command "_.DRAWORDER" s "" "_FRONT") (princ) )
Sorry Chavdar,
at my previous code change:
(if (setq ss (ssget "x" (list (CONS 0 "AECC_TIN_SURFACE")))) (progn (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vla-put-Layer obj "56-DES") ) (command "_.draworder" ss "" "_front") ) )
to
(if (setq ss (ssget "x" (list (CONS 0 "AECC_TIN_SURFACE")))) (progn (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (if (and (vlax-property-available-p obj 'DisplayName) (wcmatch (strcase (vlax-get-property obj 'DisplayName)) "56-DES*") ) (vla-put-Layer obj "56-DES") ) ) (command "_.draworder" ss "" "_front") ) )
Henrique
Hi everybody,
Tanks a lot for your support. I finished my lisp and now it is working just perfect:)
Chavdar