How to generate multiple alignments from multiple polylines.

How to generate multiple alignments from multiple polylines.

Anonymous
Not applicable
9,432 Views
48 Replies
Message 1 of 49

How to generate multiple alignments from multiple polylines.

Anonymous
Not applicable

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).Mapimport Shape with unique ID for each polylineMapimport Shape with unique ID for each polyline

Create alignment from objectsCreate alignment from objects

 

Alignment generation definition to be replicated for each polyline object.Alignment generation definition to be replicated for each polyline object.

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.

0 Likes
Accepted solutions (1)
9,433 Views
48 Replies
Replies (48)
Message 21 of 49

Anonymous
Not applicable

@txheed Were you able to get this script working in C3D 2020?

0 Likes
Message 22 of 49

mwilliamsYD7Y6
Observer
Observer

I have the same error message (parameter is incorrect).  I am using C3D 2019.

 

Were you able to make it work?

 

@tcorey

@neilyj666 

0 Likes
Message 23 of 49

Ntuthuko.
Advocate
Advocate
No I haven't. I'm still without a solution.
0 Likes
Message 24 of 49

mwilliamsYD7Y6
Observer
Observer

@tcorey 

 

In C3D 2019, running this script for me result in "; error: Automation Error. The parameter is incorrect."

 

I've attached a sample drawing, can you help me correct my issue with running the script?

 

Thanks

0 Likes
Message 25 of 49

txheed
Participant
Participant

no, i was unable to get it to work.

0 Likes
Message 26 of 49

txheed
Participant
Participant

in 2020 it returns this... ; error: no function definition: VLAX-ENAME->VLA-OBJECT

0 Likes
Message 27 of 49

tcorey
Mentor
Mentor

Here's an update to that routine.

 

;this routine converts polylines into Civil 3D Alignments

(defun c:DES_CnvrtPlineToAlign ( / plss len ctr pl algns lblsets lblset algnstys algnsty algn c3dnumber c3dproduct c3drelease c3ddoc appno acadapp acaddoc c3dapp) 
(vl-load-com)									
(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))
			  (setq algnname (strcat "Aln-Cvrt-From-Pline-(" (rtos ctr 2 0) ")"))
							(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
						)
		(setq ctr (1+ ctr))
		);end while
			
       
	(princ)
	)
						
						
	
						
						
						
						

;Thanks to Jeff Mishler for this code						
(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


Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 28 of 49

neilyj666
Mentor
Mentor

@tcorey I just tried the new version and no luck

 

2021-04-21 14_27_40-Autodesk Civil 3D 2021 - [Drawing4.dwg].jpg

 

 

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.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
0 Likes
Message 29 of 49

txheed
Participant
Participant
; error: Automation Error. The parameter is incorrect.
0 Likes
Message 30 of 49

txheed
Participant
Participant
ran it again using the imperial profile rather than our custom one and gave me the original error.... ; error: no function definition: VLAX-ENAME->VLA-OBJECT
0 Likes
Message 31 of 49

neilyj666
Mentor
Mentor

@txheed @tcorey I had to change the label sets/alignment style to ones I have in my drawing and I added my alignments layer instead of C-ROAD - all worked as expected after that

 

 

2021-04-21 14_39_19-C__AutoLisp_PolyToAlign_CnvrtPolyToAlign2022.lsp - Notepad++.jpg

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.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
Message 32 of 49

txheed
Participant
Participant
@neilyj666 maybe a 2020 issue than? it still fails on me. I opened the default Autodesk template which has layer C-ROAD and those styles in it. It still errors out.
0 Likes
Message 33 of 49

neilyj666
Mentor
Mentor
I just tried in 2020.5 and my version worked as expected


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.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
0 Likes
Message 34 of 49

mwilliamsYD7Y6
Observer
Observer

after editing styles/layers as shown by @neilyj666 (and reloading the .lsp), it is working great for me.

 

Thanks @tcorey 

0 Likes
Message 35 of 49

neilyj666
Mentor
Mentor

@mwilliamsYD7Y6 forgot to mention that the lisp would need to be reloaded....😉

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.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
0 Likes
Message 36 of 49

tcorey
Mentor
Mentor

Sorry for the delay in responding to everyone. @neilyj666 is correct. Those places in the code, where he has highlighted, are calling for alignment style, label set, name, and other values. If the label set name or the label style name that I hardcoded into the program does not existing in the drawing, this program will fail.

 

You have two choices, change the .lsp file to match your own label style and label set, or change your drawing so that it includes the ones in the code. That applies to the layer, as well.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 37 of 49

Anonymous
Not applicable

When running the lisp, I get an error message of "error: Automation Error. The parameter is incorrect."

Any help would be much appreciated. Thank you.

0 Likes
Message 38 of 49

neilyj666
Mentor
Mentor

Post 31 of the thread

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.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
0 Likes
Message 39 of 49

Anonymous
Not applicable

Thank you!

0 Likes
Message 40 of 49

Jeff_M
Consultant
Consultant

For those that are getting errors, you may just need to include (vl-load-com) to the beginning of the lisp.

Jeff_M, also a frequent Swamper
EESignature