Hi All,
I have a question that is related to automation of a simple task. My background is hydraulic modelling of water networks. A water network for a city can be an elaborate system. Civil3d has well devised import mechanism to import model data in shapefile format.
For interference analysis, profile plotting and other allied tasks, the network pipes must have associated surface and alignments. Civil3d has multiple alignment generation options. However, it seems, all require significant man-hours (when it is a city scale branched network). I can dissolve the pipe network into polylines that can be used as objects for alignment generation. For each object, I left a unique integer ID in DF field (of the shapefile).
My question is, is there any application or script that can take the polylines and generate alignment for each polyline without requiring any user intervention? Attaching a sample file that contains the polyline objects that need to be converted into alignments. For the seven polyline objects in the file, I want to generate seven corresponding alignments; preferably named 'Alignment - DF'. The process should be automated.
Much appreciate a quick response. Thanks in advance.
Solved! Go to Solution.
Solved by tcorey. Go to Solution.
@Anonymous First let me say Welcome to the Forum.
First you can't have multiple alignments with the same name that I'm aware of as you show in your example xxxx-DF so there in lies some intervention to the automation that will require some form of input from the user. Now you can place a counter after the DF that would automate creating the alignment. But to create multiple without any user input would mean that the user doesn't know where they are or how they are created.
Rick Jackson
Survey CAD Technician VI
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
You would need a *.lsp routine for this. I recommend posting on the C3D customization forum (here) for help with creating said lsp. While you can not have multiple alignments with the same name, you can have multiple alignments with the same description and use the description in place of the name for mast things.
;this routine converts polylines into Civil 3D Alignments ;significant thanks to Jeff Mishler for his help (defun c:DES_CnvrtPlineToAlign ( / plss len ctr pl algns lblsets lblset algnstys algnsty algn c3dnumber c3dproduct c3drelease c3ddoc appno acadapp acaddoc c3dapp) (getdoc) (prompt "\nSelect Polylines: ") (setq plss (ssget) len (sslength plss) ctr 0) (while (< ctr len) (setq pl (vlax-ename->vla-object (ssname plss ctr))) (if (= (vlax-get pl 'ObjectName) "AcDbPolyline") (progn (setq algns (vlax-get c3ddoc 'AlignmentsSiteless)) (setq lblsets (vlax-get c3ddoc 'alignmentlabelstylesets) lblset (vlax-get-property lblsets 'item "Major and Minor only") algnstys (vlax-get c3ddoc 'AlignmentStyles) algnsty (vlax-get-property algnstys 'Item "Proposed") ) (setq algn (vlax-invoke-method algns 'addfrompolyline "fromPolyline" ;new alignment name "C-ROAD" ;layer (vla-get-objectid pl) ;pline object id algnsty ;alignment style lblset ;alignment label set :vlax-false ;add curves between tangents :vlax-false) ;delete existing entites ) ))(setq ctr (1+ ctr)))(princ)) (defun getAecAppNumber (/ ) (setq C3Dproduct (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) ) C3Drelease (vl-registry-read C3Dproduct "Release") C3Dnumber (substr C3Drelease 1 (vl-string-search "." C3Drelease (+ (vl-string-search "." C3Drelease) 1) ) ) ) ) (defun getdoc ( / ) (setq appno (getaecappnumber)) (setq acadapp (vlax-get-acad-object) c3dapp (vla-getinterfaceobject acadapp (strcat "AeccXUiLand.AeccApplication." appno)) C3Ddoc (vla-get-activedocument C3Dapp) ) ) ;end function
Thanks for your feedbacks.
Sorry for the confusion. My earlier question lacked details. The polylines are created from pipes dissolved into desired profile scopes.
Actually, the intention is 'not' to create alignments with same name. That's why, I have imported 'DF' variable (a field in the shape file with integer values 1,2,3...,7) as an object data associated with each polyline. So, if one polyline will have associated 'DF' object data as, say, '1' then, it's alignment will have name, 'Alignment -1' while the polyline with 'DF' 5 will have Alignment named as 'Alignment-5'. That is the expectation.
Much appreciate your insight.
Thanks a lot for the lisp code! It 'almost' did what was requested. My earnest thanks to Mr. Mishlar for the lisp code.
There is a 'DF' variable (a field in the shape file with integer values 1,2,3...,7) imported as object data associated with each polyline. So, if one polyline will have associated 'DF' object data as, say, '1' then, it's alignment will have name, 'Alignment -1' while the polyline with 'DF' 5 will have Alignment named as 'Alignment-5' as so on. So, getting the naming part done will be a big help.
It seems, the code skips polylines with only two vertices (lines with start and end vertex only). Is there a way to modify the code so that all polylines will be considered?
Thanks a lot for your assistance.
Regards,
Imtiaz
@Anonymous , If you post a drawing that includes the object data, I can quickly make the naming change. Or tell me the name of the Object Data Table and the Field name from which to capture the number.
If you can't post, send to me directly: tcorey at shasta dot com
As far as skipping polylines with two vertices, I don't find that to be true. Maybe the entities are Lines, not Polylines. Use PEDIT command, Multiple, to turn them into Polylines, before running this LISP.
Best regards,
Tim
neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Dear Mr. Corey,
Many thanks for your tip! Indeed, after pedit, multiple fix, all alignments were generated from the polyline file. I am attaching the polyline file. This is just a test case file. With each polyline, an object data variable 'DF' contains an integer value. Is there any way the Lisp code can be enhanced to collect the DF integer value and name the alignment created with it as a suffix? For example, if DF = 1, Alignment-1 or if If DF = 5, Alignment-5 and so on.
Many thanks for your help.
Regards,
Imtiaz
I should be able to do this by Monday...
Try this.
;this routine converts polylines into Civil 3D Alignments ;significant thanks to Jeff Mishler for his help ;Rev B converts lines into polylines, with object data intact.No help from Jeff. (defun c:DES_CnvrtPlineToAlign ( / plss len ctr pl algns lblsets lblset algnstys algnsty algn c3dnumber c3dproduct c3drelease c3ddoc appno acadapp acaddoc c3dapp) (getdoc) (prompt "\nSelect Polylines: ") (setq plss (ssget) len (sslength plss) ctr 0) (setq algns (vlax-get c3ddoc 'AlignmentsSiteless)) (setq lblsets (vlax-get c3ddoc 'alignmentlabelstylesets) lblset (vlax-get-property lblsets 'item "Major and Minor only") algnstys (vlax-get c3ddoc 'AlignmentStyles) algnsty (vlax-get-property algnstys 'Item "Proposed") ) (while (< ctr len) (setq ple (ssname plss ctr)) (setq pl (vlax-ename->vla-object ple)) (cond ((= (vlax-get pl 'ObjectName) "AcDbPolyline") (getade) (setq algn (vlax-invoke-method algns 'addfrompolyline algnname ;new alignment name "C-ROAD" ;layer (vla-get-objectid pl) ;pline object id algnsty ;alignment style lblset ;alignment label set :vlax-false ;add curves between tangents :vlax-false) ;delete existing entites ) ) ((= (vlax-get pl 'ObjectName) "AcDbLine") (getade) (vl-cmdf "pedit" ple "y" "") (setq newrecid (ade_odNewRecord "Alignment2")) (setq ple (entlast)) (setq pl (vlax-ename->vla-object ple)) (ade_odattachrecord ple newrecid) (ade_odsetfield ple "alignment2" "DF" 0 namesfx) (setq algn (vlax-invoke-method algns 'addfrompolyline algnname ;new alignment name "C-ROAD" ;layer (vla-get-objectid pl) ;pline object id algnsty ;alignment style lblset ;alignment label set :vlax-false ;add curves between tangents :vlax-false) ;delete existing entites ) ) (t nil) ) (setq ctr (1+ ctr)) ) (princ) ) (defun getade () (setq recno (ade_odgetrecord ple "Alignment2" 0)) (setq namesfx (ade_odgetrecfield recno "DF")) (setq algnname (strcat "Alignment-" (itoa namesfx))) ) (defun getAecAppNumber (/ ) (setq C3Dproduct (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) ) C3Drelease (vl-registry-read C3Dproduct "Release") C3Dnumber (substr C3Drelease 1 (vl-string-search "." C3Drelease (+ (vl-string-search "." C3Drelease) 1) ) ) ) ) (defun getdoc ( / ) (setq appno (getaecappnumber)) (setq acadapp (vlax-get-acad-object) c3dapp (vla-getinterfaceobject acadapp (strcat "AeccXUiLand.AeccApplication." appno)) C3Ddoc (vla-get-activedocument C3Dapp) ) ) ;end function
I would need to get a sample drawing from you. The code should work the same in 2020 as previous versions.
Attached is an example of the Road Centerlines
Command: DES_CNVRTPLINETOALIGN
Select Polylines:
Select objects: 1 found
Select objects:
; error: no function definition: VLAX-ENAME->VLA-OBJECT
Open Notepad, paste the code and save as a new file e.g. "newfile.lsp" - make sure you put it in quotation marks
On the Civil command line, APPLOAD and browse to the file just saved and load it - be aware it failed when I just tried
On the command line type DES_CNVRTPLINETOALIGN
Select Polylines:
Select objects: Specify opposite corner: 8 found
Select objects:
; error: Automation Error. The parameter is incorrect.
Command:
neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Hi There
I've loaded the lisp. When I run it, it says "error, no function definition GETDOC."
Please help.
Thanks
Ntuthuko
Thank you, much appreciated!
I have loaded the LISP successfully but when I run it, it says, "error, no function definition: GETDOC." Any idea how I can resolve this?
Thanks
Ntuthuko
No idea prhaps @tcorey can assist..?
neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Can't find what you're looking for? Ask the community or share your knowledge.