Is it possible to create a selection from a group of points to assign to a different layer?
Or a ssget function to select by point description?
Point are Civil Point Objects
PNEZD format and parsing out the (D)escription
Using Civil 3D 2009
|
Is it possible to create a selection from a group of points to assign to a different layer?
Or a ssget function to select by point description?
Point are Civil Point Objects
PNEZD format and parsing out the (D)escription
Using Civil 3D 2009
Last edited by sdrewinc432892; 2016-08-04 at 12:35 PM.
Why not create a PointGroup based on Description, and set the Point Style for that group?
The short answer is yes, but with with Civil3d is never a straight forward and simple as it seems. You can create a point group and set that to a style on the layer you want then put that group up in the higher hierarchy. you can also select the points and place them on the layer you want. However for both methods remember like with everything controlled by a style you have multiple nested layers.
Manual effort to setup/tweak a Point Group to include the needed description(s), etc, is pretty minimal. That would make it easy to right click + select the desired points, and then adjust the LAYER in Properties Pane.
That said, of the few Civil Objects exposed to LISP, COGO Points were one of the first I found, and really easy to work with.
I'll stop back tomorrow as workload permits.
Cheers
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
I'm thankful the developers have allowed LISP access to COGO Points. It's allowed me to assign specific points to a Point Group. I'm still don't have the time to jump fully into .NET.
If you have a technical question, please find the appropriate forum and ask it there.
You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
jUSt
If the COGO Points are already in the drawing, you can select by Raw Description (written back in 2012):
Code:;;;--------------------------------------------------------------------; ;;; Keyboard shortcut: (defun c:SSRD () (c:SelectionSetRawData)) ;;;--------------------------------------------------------------------; ;;; SelectionSetRawData function: (defun c:SelectionSetRawData (/ rawData ss) (vl-load-com) (if (and (setq rawData (getstring T "\nEnter raw data string to match: ")) (setq ss (_SelectionSetRawData rawData))) (sssetfirst nil ss) (prompt "\n** Nothing selected ** ")) (princ)) ;;;--------------------------------------------------------------------; (defun _SelectionSetRawData (prefix / ss ssCogo) (if (setq ss (ssget "_x" (list '(0 . "AECC_COGO_POINT") (cons 410 (getvar 'ctab))))) (progn (setq ssCogo (ssadd)) (vlax-for x (setq ss (vla-get-activeselectionset acDoc)) (if (wcmatch (vlax-get x 'rawdescription) prefix) (setq ssCogo (ssadd (vlax-vla-object->ename x) ssCogo)))) (vla-delete ss) ssCogo) ) ) ;;;--------------------------------------------------------------------;
If the COGO Points do not yet exist, and you need to import a point range:
Cheers
Last edited by BlackBox; 2016-08-05 at 01:54 PM.
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
As am I - only after recent events in Customer Council (AutoCAD Alpha/Beta forums), have I realized just how much better the Civil 3D team is than the AutoCAD team; literally worlds apart, better.
I'm still quite unhappy with many facets of Civil 3D, but the Civil 3D team actually does make improvements with enough noise... The AutoCAD team on the other hand, just tells you what they're doing, gives you **** when you don't drink the coolaide and convince them that you like it, and refuses to listen to anything we ask for, regardless of our politely asking, firmly requesting, or outright demanding.
I'm convinced that a small handful of us (here in this thread necessary) could do better... They don't understand (or care) who their customers are, and what's important to them, and the few that have real-world production experience, were last relevant 20+ years ago, which explains their comfort with the status quo.
/Vent
Just an observation (albeit on my system), you'll see improved performance with While + Cons over Repeat + Append when iterating a SelectionSet; although, iterating ActiveSelectionSet using Vlax-For is faster still.
Quick speed test:
Code:(setq ss (ssget '((0 . "AECC_COGO_POINT")))) ;;(defun SelectPoints->List (ss / scnt lstNumbers) (defun _RepeatAppend (ss / scnt lstNumbers) ;;(setq ss (ssget '((0 . "AECC_COGO_POINT")))) (repeat (setq scnt (sslength ss)) (setq lstNumbers (append lstNumbers (list (vlax-get-property (vlax-ename->vla-object (ssname ss (setq scnt (1- scnt)))) 'Number ) ) ) ) ) ) (defun _WhileCons (ss / i e lstNumbers) (setq i -1) (while (setq e (ssname ss (setq i (1+ i)))) (setq lstNumbers (cons (vlax-get (vlax-ename->vla-object e) 'number ) lstNumbers ) ) ) ) (defun _vlax-for (ss / cogoNums) (if ss (progn ;; assumes that acDoc is defined in the calling function (vlax-for x (setq ss (vla-get-activeselectionset acDoc)) (setq cogoNums (cons (vlax-get x 'number) cogoNums)) ) (vla-delete ss) cogoNums ) ) )
... And results from console:
Code:_$ (bench '(_RepeatAppend _WhileCons _vlax-for) (list ss) 100) _REPEATAPPEND Elapsed: 1047 Average: 10.4700 _WHILECONS Elapsed: 953 Average: 9.5300 _VLAX-FOR Elapsed: 906 Average: 9.0600 _$
It's not as approachable as I wish it were, but I'm very thankful that I've invested the time - I wouldn't have had the opportunities to publish Exchange apps (with the same level of performance, if at all), or even work with the SincPac C3D team, had I not taught myself .NET (with a great deal of help from other, of course).
The best advise I can offer, is to go get a current/applicable book for the .NET Framework version you plan to learn/use for the next year - I highly recommend Andrew Troelsen's books, mine is +/-1800 pages - and simply learn .NET _outside_ of AutoCAD for a year. Then come back and apply what you know of .NET, to AutoCAD's .NET API.
I struggled to learn AutoCAD's .NET API, jumping from Visual LISP (ActiveX) to VB.NET, initially thinking the syntax would be easier for me to adapt to. However, despite the similarities they do share, I later learned that .NET != VBA (ActiveX), and ended up finding it substantially easier to instead learn C# from scratch (hence the book mention above). Made it worlds easier for me to compartmentalize APIs, until I got over the initial hump, and better understood .NET generally.
... My $0.01.
Cheers
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Here are some other general COGO Point-related snippets....
Miscellaneous sub-functions:
Code:;;;--------------------------------------------------------------------; ;;; Points (defun C3d-Get-CogoPoints (oDoc / cogoPoints) ;; BlackBox, 2012 ;; Example: (if (C3d-Get-CogoPoints acDoc) T nil) ;; Return: (# <list>) (vlax-for x (vla-get-block (vla-get-layout (vla-get-modelspace oDoc))) (if (= (vla-get-objectname x) "AeccDbCogoPoint") (setq cogoPoints (cons x cogoPoints)) ) ) (if cogoPoints (cons (length cogoPoints) (reverse cogoPoints)) ) ) ;;;---------------------------------------------------------------------; ;;; COGO Point Number (defun C3d-Get-CogoNumber (cogo) (vlax-get cogo 'number) ) (defun C3d-Set-CogoNumber (cogo cogoNumber) (vlax-put cogo 'number cogoNumber) ) ;;;---------------------------------------------------------------------; ;;; COGO Point Elevation (defun C3d-Get-CogoElevation (cogo) (vlax-get cogo 'elevation) ) (defun C3d-Set-CogoElevation (cogo cogoElevation) (vlax-put cogo 'elevation cogoElevation) ) ;;;---------------------------------------------------------------------; ;;; COGO Point Label Style (defun C3d-Get-CogoLabelStyle (cogo) (vlax-get (vlax-get cogo 'labelstyle) 'name) ) (defun C3d-Set-CogoLabelStyle (cogo labelStyleName) (vlax-put (vlax-get cogo 'labelstyle) 'labelStyleName) ) ;;;---------------------------------------------------------------------; ;;; COGO Point Style (defun C3d-Get-CogoStyle (cogo) (vlax-get (vlax-get cogo 'style) 'name) ) (defun C3d-Set-CogoStyle (cogo styleName) (vlax-put (vlax-get cogo 'style) 'styleName) ) ;;;---------------------------------------------------------------------; ;;; Sample function (defun c:ListCogo (/ *error* ss) (defun *error* (msg) (if ss (vla-delete ss) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (if (ssget ":S:E" '((0 . "AECC_COGO_POINT"))) (progn (prompt "\nPoint Number, Point Elevation, Point Label Style, Point Style " ) (vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)) ) ) (prompt (strcat "\n" (itoa (C3d-Get-CogoNumber x)) ", " (rtos (C3d-Get-CogoElevation x) 2 2) ", " (C3d-Get-CogoLabelStyle x) ", " (C3d-Get-CogoStyle x) ) ) ) (terpri) ) ) (*error* nil) ) ;;;--------------------------------------------------------------------;
Convert (in my case Eagle Point) Blocks to COGO Points:
Code:(defun c:ConvertBlockToCogo (/ *error* vrsn acApp aeccApp aeccDoc aeccDb oPoints acDoc n ss oPoint pt blockName) (defun *error* (msg) (if ss (vla-delete ss) ) (if aeccApp (vlax-release-object aeccApp) ) (if acDoc (vla-endundomark acDoc) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (if (and (ssget "_:L" '((0 . "INSERT"))) (setq vrsn (if vlax-user-product-key ; If 2013+ (vlax-user-product-key) ; Use new function (vlax-product-key) ; Use legacy function ) ) (setq vrsn (cond ((vl-string-search "21.0" vrsn) "11.0") ; 2017 ((vl-string-search "20.1" vrsn) "10.5") ; 2016 ((vl-string-search "20.0" vrsn) "10.4") ; 2015 ((vl-string-search "19.1" vrsn) "10.3") ; 2014 ((vl-string-search "19.0" vrsn) "10.0") ; 2013 ((vl-string-search "18.2" vrsn) "9.0") ; 2012 ((vl-string-search "18.1" vrsn) "8.0") ; 2011 ((vl-string-search "18.0" vrsn) "7.0") ; 2010 ((vl-string-search "17.2" vrsn) "6.0") ; 2009 ((vl-string-search "17.1" vrsn) "5.0") ; 2008 (T nil) ) ) (setq aeccApp (vla-getinterfaceobject (setq acApp (vlax-get-acad-object)) (strcat "AeccXUiLand.AeccApplication." vrsn) ) ) (setq aeccDoc (vlax-get-property aeccApp "ActiveDocument")) (setq aeccDb (vlax-get-property aeccDoc "Database")) (setq oPoints (vlax-get-property aeccDb "Points")) (princ "\nWorking, please wait... ") (princ) ) (progn (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) (setq n 0) (vlax-for x (setq ss (vla-get-activeselectionset acDoc)) (setq oPoint (vlax-invoke-method oPoints 'add (vlax-3d-point (setq pt (vlax-get x 'insertionpoint)) ) ) ) (vla-put-description oPoint (setq blockName (vla-get-effectivename x)) ) (vla-put-elevation oPoint (last pt)) (vla-put-layer oPoint (vla-get-layer x)) (cond ((= blockName "51") ; benchmarks (foreach attrib (vlax-invoke x 'GetAttributes) (if (= "PD" (vla-get-tagstring attrib)) (vl-catch-all-apply 'vlax-put-property (list oPoint 'name (vla-get-textstring attrib)) ) ) ) ) ((= blockName "182") ; steel posts (progn (vla-add (vla-get-layers acDoc) (setq layerName (strcat (vla-get-layer x) "-TX")) ) (foreach attrib (vlax-invoke x 'GetAttributes) (if (= "PD" (vla-get-tagstring attrib)) (progn (setq oTreeLabel (vlax-invoke-method oPoints 'add (vlax-3d-point pt) ) ) (vla-put-description oTreeLabel (vl-string-subst "-" " " (vla-get-textstring attrib) ) ) (vla-put-elevation oTreeLabel (last pt)) (vla-put-layer oTreeLabel layerName) ) ) ) ) ) ((wcmatch blockName "2##") ; trees (progn (vla-add (vla-get-layers acDoc) (setq layerName "E-TREE-TX") ) (foreach attrib (vlax-invoke x 'GetAttributes) (if (= "PD" (vla-get-tagstring attrib)) (progn (setq oTreeLabel (vlax-invoke-method oPoints 'add (vlax-3d-point pt) ) ) (vla-put-description oTreeLabel (vl-string-subst "-" " " (vla-get-textstring attrib) ) ) (vla-put-elevation oTreeLabel (last pt)) (vla-put-layer oTreeLabel layerName) ) ) ) ) ) ) ;; point number (foreach attrib (vlax-invoke x 'GetAttributes) (if (= "PN" (vla-get-tagstring attrib)) (vl-catch-all-apply 'vlax-put-property (list oPoint 'number (vla-get-textstring attrib)) ) ) ) (vlax-put-property oPoint 'rotation (vla-get-rotation x)) (vla-delete x) (setq n (1+ n)) ) (prompt (strcat "\n** " (itoa n) " block" (if (= 1 n) "" "s") " processed ** ")) (vlax-for x (vlax-get-property aeccDb "PointGroups") (vl-catch-all-apply 'vlax-invoke-method (list x 'update)) ) (vla-regen acDoc acAllViewports) ) ) (*error* nil) )
[Edit] - Grrr... Stupid 10,000 character limit; see next post.
Cheers
- - - Updated - - -
Grrr again... The new 'auto-combine posts when same user makes another post' malarkey won't let me post the last (shorter) code snippet, as it's combining the overall length, instead of making a new post.
- - - Updated - - -
... Still... Cannot... Post it.
- - - Updated - - -
... What... A... Pain... In... The... Hind... Quarters
- - - Updated - - -
... This... Is... Ridiculous
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Last edited by BlackBox; 2016-08-05 at 02:40 PM. Reason: Removed the unrelated code, etc. from the quote being replied to
... Finally, able to post the continuation:
Code:(vl-load-com) (defun c:RaiseLowerCogo (/ *error* elev acDoc ss) (defun *error* (msg) (if ss (vla-delete ss)) (if acDoc (vla-endundomark acDoc) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) (if (and (ssget "_:L" '((0 . "AECC_COGO_POINT"))) (or *RaiseLowerCogoElevation* (setq *RaiseLowerCogoElevation* 1.0) ) (or (setq elev (getreal (strcat "\nSpecify elevation difference <" (rtos *RaiseLowerCogoElevation* 2 3) ">: " ) ) ) (setq elev *RaiseLowerCogoElevation*) ) (/= 0.0 elev) (setq *RaiseLowerCogoElevation* elev) ) (progn (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) (setq i (vla-get-count (setq ss (vla-get-activeselectionset acDoc)) ) ) (setq n 0) (vlax-for x ss (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-elevation (list x (+ (vla-get-elevation x) elev)) ) ) ) (setq n (1+ n)) ) ) (prompt (strcat "\n" (itoa n) " of " (itoa i) " COGO Point" (if (= 1 i) " was " "s were " ) (if (< 0 elev) "raised " "lowered " ) (rtos elev 2 3) "' " ) ) ) (if (= 0.0 elev) (prompt "\nValue must nonzero. ") ) ) (*error* nil) )
Cheers
- - - Updated - - -
Edit to add, for the sake of levity -
Here's how you do that same thing in .NET
Ehhehehe
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000