reza Posted May 3 Posted May 3 (edited) Hello everyone. Is it possible to write a program in C# that can increase or decrease an alignment in Civil 3D 2019 from its end? Assuming that the last alignment segment can be a line or an arc. Just in case this is possible, I need a .dll file that can be run in Civil 3D 2019. because I don't have Visual Studio and I don't know how to use it. With many thanks to the dear programmers. Edited May 3 by reza Quote
BIGAL Posted May 4 Posted May 4 (edited) I used CSD sitting on top of CIV3D but I am pretty sure you do not need a program, if you kept the original pline defining the alignment you can amend it and remake the Alignment. Give it a try please let me know. Forums/autodesk has a CIV3D forum maybe ask there also. I know with lisp can get at the Alignment may not need C#. Alignment properties ; write out alignment details version 1 ; by Alan H Oct 2019 (defun c:alignlab (/ ste stn ende endn len ch ans fo fname delta ) (setq seg 1) (setq dwgname (vl-filename-base (getvar 'dwgname))) (setq fname (strcat (getvar 'dwgprefix) dwgname ".csv")) (setq fo (open fname "w")) ;(setq ans "Segment,Ch,StationE,StationN,EndstE,ENDstN,Length,CenterE,CentreN,Rad,Delta,Tanlength") (setq ans "Segment,Ch,StationE,StationN,Length,CenterE,CentreN,Rad,Delta,Tanlength") (write-line ans fo) (setq obj (vlax-ename->vla-object (car (entsel "pick Alignment")))) (vlax-for objid (vlax-get-property obj 'entities) (setq altyp (vla-get-type objid)) (setq ch (rtos (vlax-get-property objid 'StartingStation) 2 3)) (setq stE (rtos (vlax-get-property objid 'StartEasting) 2 3)) (setq stN (rtos (vlax-get-property objid 'StartNorthing) 2 3)) (setq endE (rtos (vlax-get-property objid 'EndEasting) 2 3)) (setq endN (rtos (vlax-get-property objid 'EndNorthing) 2 3)) (setq chend (rtos (vlax-get-property objid 'EndingStation) 2 3)) (setq len (rtos (vlax-get-property objid 'Length))) ;(setq ans (strcat (rtos seg 2 0) "," ch "," ste "," stn "," ende "," endn "," len)) (setq ans (strcat (rtos seg 2 0) "," ch "," ste "," stn "," len)) (if (= altyp 2) (progn (setq cenE (rtos (vlax-get-property objid 'CenterEasting) 2 3)) (setq cenN (rtos (vlax-get-property objid 'CenterNorthing) 2 3)) (setq rad (rtos (vlax-get-property objid 'radius) 2 3)) (setq delta (vlax-get-property objid 'delta)) (setq delta (rtos (/ (* delta 180.0) pi) 2 3)) (setq tang (rtos (vlax-get-property objid 'ExternalTangent) 2 3)) (setq PIStn (rtos (vlax-get-property objid 'PIStation) 2 3)) (setq ans (strcat ans "," cene "," cenn "," rad "," delta "," tang)) ) ) (write-line ans fo) (princ ans) (princ "\n") (setq ans nil) (setq seg (+ seg 1)) ) (setq ans (strcat (rtos seg 2 0) "," chend "," ende "," endn )) (write-line ans fo) (close fo) (alert (strcat "All done look in \n\n" fname)) (princ) ) (c:alignlab) (defun test () (setq obj (vlax-ename->vla-object (car (entsel "pick Alignment")))) (vlax-for objid (vlax-get-property obj 'entities) (vlax-dump-object objid) ) ) Edited May 4 by BIGAL 1 Quote
reza Posted May 4 Author Posted May 4 (edited) Hi bigal: thank you for reply The code you posted extracts the alignment information correctly. Is it possible to change the alignment length in the next step? It is possible to access and convert an alignment to a pline. in which case there is no need for a program at all, and I can modify the pline with LENGTHEN command and convert it back to an alignment. but I didn't want to go that route. I asked this question in the Civil forum at Autodesk and did not receive an answer. Edited May 4 by reza Quote
BIGAL Posted May 4 Posted May 4 We always tried to keep the original pline, so your task would be easy. I am not sure the time involved for me to go hunting the StartingStation and then the next vertice as modify start or get endingstation and vertice before the end again to be modified. A choice change start or end. When you change an alignment you must somehow redo it so the CIV3D database is updated. There is sample code for CIV3D. Look in you c:\program files\autodesk....samples... \vba pretty sure there was one for Alignments. May have the details you want. Quote
reza Posted May 5 Author Posted May 5 Dear Bigal: I have been trying hard to do this with Visual Basic and C# for the past month (with help from ChatGPT). but I have encountered many problems (numerous errors in Visual Basic and in generating DLLs in C#). and it seems that this is not possible with Lisp either. I would appreciate it if you, as a knowledgeable and experienced person, could tell me whether I should give up on this project or not. Quote
SLW210 Posted May 5 Posted May 5 Maybe try StackOverflow or similar and ask. Newest Questions - Stack Overflow You should also ask in the Civil 3D Customization Forum - Autodesk Community When was the last time Civil 3D 2019 had an update? I have found every time Windows updates, I get a few more problems with older programs, though most work, they seem to get quirky. I know nothing of Civil 3D, though I have had to manually do alignments in AutoCAD, I am no expert by any means. So, maybe try to explain what you want in details like you were writing an "Alignments for Dummies" book. Quote Assuming that the last alignment segment can be a line or an arc If you can, please explain exactly what Civil 3D calls the the last alignment segment. Assuming is not helpful. There are a ton of step-by-step tutorials for using MS Visual Studio, download it and give it a shot. 1 Quote
reza Posted May 5 Author Posted May 5 Thank you for your attention, Mr.SLW210 As I said, I asked this question a while ago in the forum you mentioned and I didn't get an answer. As far as I know, this feature is not available in new versions of Civil 3d. Because I am not familiar with Visual Basic and C#, I cannot help myself in generating the DLL file. Although I tried to do it myself with the instructions I received, it did not work and the task is more complicated than I can do. You assume that the end of the alignment can be a line or an arc. In this case, the increase and decrease in length should be done from the end of the alignment, which may be the amount of decrease that includes the arc if the end of the alignment is a line and there is an arc before it. Or, in short, think about it this way: you want to execute the LENGTHEN(Total) command on the alignment instead of on the polyline. test.dwg Quote
SLW210 Posted May 5 Posted May 5 https://forums.autodesk.com/t5/civil-3d-customization-forum/alinment-total-length-multiple-alignment-amp-lengthen-total/m-p/13335681#M27177 I think that's you then. https://forums.augi.com/showthread.php?177987-increase-or-decrease-an-alignment-in-civil-3d-2019&p=1357683&viewfull=1#post1357683 Also this one. Like I stated, I do not have Civil 3D, I need to know what type of objects we are dealing with. Your file just shows AEC_Proxy_Object in AutoCAD. I have the .rar from the other thread, but reluctant to do the .dll from the comments of Jeff M and mostly because I can't test it, but I will look at it when I have time. You might also ask on TheSwamp - .NET 1 Quote
reza Posted May 5 Author Posted May 5 Yes, that's absolutely true. If you don't have the Civil 3d Object Enabler installed, Civil objects in AutoCAD will be displayed as proxies. Quote
SLW210 Posted May 5 Posted May 5 What exactly was the issue with the files in the .rar you posted at Autodesk Forums? It has .dll files in it. Quote
reza Posted May 5 Author Posted May 5 Thanks for your follow-up. The zip file contains the DLL files in Civil 3d 2019 folder that are needed to generate the final DLL in the C# file written by ChatGPT. Quote
BIGAL Posted May 6 Posted May 6 (edited) Personally give up on ChatGP, I also use Copolit and both from posts here and my attempts the code produced just does not work often. If you go back to my code about the alignments it shows the points of the allignment, you should be able to do a PUT rather than a get. Will see if I can do something. I am using Bricscad at moment, but have access to CIV3D just not at hand or would look at dumping alignment points as you need the last segment. Edited May 6 by BIGAL 1 Quote
BIGAL Posted May 6 Posted May 6 For anyone interested here is some sample code for make an alignment. AlignmentSample.dvb Readme.txt 1 Quote
reza Posted May 6 Author Posted May 6 I also agree with you that chatgpt often make a lot of errors, especially if your question is a bit complicated. Quote
BlackBox Posted Tuesday at 02:18 PM Posted Tuesday at 02:18 PM (edited) On 5/3/2025 at 6:52 AM, reza said: Hello everyone. Is it possible to write a program in C# that can increase or decrease an alignment in Civil 3D 2019 from its end? Assuming that the last alignment segment can be a line or an arc. Just in case this is possible, I need a .dll file that can be run in Civil 3D 2019. because I don't have Visual Studio and I don't know how to use it. With many thanks to the dear programmers. IMHO, if you're not using Visual Studio Community (free) or familiar with .NET API, you really should stop asking for .NET code, as you won't be able to do anything with it even if someone gives it to you. On 5/4/2025 at 7:35 PM, BIGAL said: We always tried to keep the original pline, so your task would be easy. I am not sure the time involved for me to go hunting the StartingStation and then the next vertice as modify start or get endingstation and vertice before the end again to be modified. A choice change start or end. When you change an alignment you must somehow redo it so the CIV3D database is updated. There is sample code for CIV3D. Look in you c:\program files\autodesk....samples... \vba pretty sure there was one for Alignments. May have the details you want. We do not keep the original plines, but can always get them back... here's an old LISP that I've since ported to .NET as a ContextMenu (right click menu) to quickly extract polylines for one or more Alignments. Since C3D Alignment object's EndingStation and StartingStation properties are read-only for LISP API, OP should use something like this, combined with (command "._lengthen" "_t") to set the total length, or (command "._lengthen" "_de") to increase/decrease overall length, then manually modify the Alignment via grips or remove/add geometry. (vl-load-com) (defun c:GetAlgnPlines (/ *error* acDoc clayer 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 (ssget "_:L" '((0 . "AECC_ALIGNMENT"))) (progn (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) (setq clayer (getvar 'clayer)) (vlax-for x (setq ss (vla-get-activeselectionset acDoc)) (vla-put-layer (vlax-invoke x 'getlwpolyline) clayer) ) ) ) (*error* nil) ) On 5/5/2025 at 10:55 AM, SLW210 said: https://forums.autodesk.com/t5/civil-3d-customization-forum/alinment-total-length-multiple-alignment-amp-lengthen-total/m-p/13335681#M27177 I think that's you then. https://forums.augi.com/showthread.php?177987-increase-or-decrease-an-alignment-in-civil-3d-2019&p=1357683&viewfull=1#post1357683 Also this one. Like I stated, I do not have Civil 3D, I need to know what type of objects we are dealing with. Your file just shows AEC_Proxy_Object in AutoCAD. I have the .rar from the other thread, but reluctant to do the .dll from the comments of Jeff M and mostly because I can't test it, but I will look at it when I have time. You might also ask on TheSwamp - .NET Viewing the source code first may help reduce reluctance in the future: https://www.jetbrains.com/decompiler/# On 5/5/2025 at 8:04 PM, BIGAL said: Personally give up on ChatGP, I also use Copolit and both from posts here and my attempts the code produced just does not work often. If you go back to my code about the alignments it shows the points of the allignment, you should be able to do a PUT rather than a get. Will see if I can do something. I am using Bricscad at moment, but have access to CIV3D just not at hand or would look at dumping alignment points as you need the last segment. FWIW, CopIlot uses ChatGPT, so it really depends on your subscription as to which tier/models you have access to. As example, with M365 subscription you have access to ChatGPT-4 model (specifically the GPT-4-turbo variant), which is better than the free ChatGPT models (last I checked), but having a ChatGPT subscription provides you access to better models. HTH Edited Tuesday at 02:20 PM by BlackBox 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.