Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code to edit a civil 3d raw description to include Station from an alignment.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
658 Views, 5 Replies

Code to edit a civil 3d raw description to include Station from an alignment.

Hello, I'm not a programmer but I dabble a bit. I looking to write a program where you pick your alignment then pick your civil 3d point, it then edits the raw description of civil point to include that station. 

Rick48JA7_0-1619800974276.png

 

 

It does not need to insert the alignment label I just need the stationing from it. I have some bits and pieces of code but nothing that all makes sense together. I really could use a hand on this one. Much Appreciated.

5 REPLIES 5
Message 2 of 6
hosneyalaa
in reply to: Anonymous

hello

try

(defun c:testStationlign (/ align bearing dist east idx inrange north off os pt ptent range ssalign sspts sta)
  (if (and
	(princ "\Select points: ")
	(setq sspts (ssget '((0 . "AECC_COGO_POINT"))))
	(princ "\nSelect alignment: ")
	(setq ssalign (ssget ":S" '((0 . "AECC_ALIGNMENT"))))	
	)
    (progn
      (setq
	    idx -1
	    align (vlax-ename->vla-object (ssname ssalign 0))
	    )
      
      (while (setq ptent (ssname sspts (setq idx (1+ idx))))
	(setq pt (vlax-ename->vla-object ptent)
	      east (vlax-get pt 'easting)
	      north (vlax-get pt 'northing)
	      )
	;;http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccAlignment__StationOffsetEx@[in]_double@[in]_double@[in]_double@[out]_double_@[out]_double_@[out,_retval]_AeccAlignmentReturnValue_.htm
	
	(if (= 0 (setq inrange (vlax-invoke-method align 'stationoffsetex east north 0.0001 'sta 'off)))
	  (progn

	    (vlax-put-property pt 'LabelStyle "Point#-Elevation-Description")
		  
		    (vla-put-description pt (strcat "Station =" (RTOS sta 2 3 )))
	    
	    )
	 
	  )
	)
      
      
      )
    )
  (princ)
  )

 

 

 

1.PNG2.PNG

Message 3 of 6
Jeff_M
in reply to: Anonymous

This little lisp has you select an alignment, then it prompts to select points, it will continue as long as you select a point.

 

(defun c:sta2desc(/ ALIGN ALNENT DESC I OFF PT PTSS STA STATION)
  (if (and (setq alnEnt (entsel "\nSelect alignment: "))
	   (setq align (vlax-ename->vla-object (car alnEnt)))
	   (= (vla-get-objectname align) "AeccDbAlignment")
	   )
    (progn
      (while (setq ptSS (ssget '((0 . "AECC_COGO_POINT"))))
	(setq i -1)
	(while (setq pt (vlax-ename->vla-object (ssname ptSS (setq i (1+ i)))))
	  (setq sta nil
	        off nil)
	  (vlax-invoke-method align 'stationoffset (vlax-get pt 'easting) (vlax-get pt 'northing) 'sta 'off)
	  (if (/= nil sta)
	    (progn
	      (setq station (vlax-invoke align 'getstationstringwithequations sta))
	      (setq desc (strcat (vlax-get pt 'rawdescription) "|" station))
	      (vlax-put pt 'rawdescription desc)
	      )
	    )
	  )
	)
      )
    )
  (princ)
  )
Jeff_M, also a frequent Swamper
EESignature
Message 4 of 6
Anonymous
in reply to: Jeff_M

Amazing Jeff, I just have to round the sta to nearest ft now.

Any fast way to round a sta with the + in it to nearest ft? I tried converting to a real number then back to a string after rounding but that didn't work. Instead of using getstationstringwithequations should I use something else to give me a real number I can round? getstationstring  ?

 

Message 5 of 6
Jeff_M
in reply to: Anonymous

The GetStationStringWithEquations uses the Precision setting in the Alignment Feature settings. Set that to the desired value and you won't need to do any adjustments.

Jeff_M, also a frequent Swamper
EESignature
Message 6 of 6
Jeff_M
in reply to: Jeff_M

Or, without editing the precision setting:

 

(setq desc (strcat (vlax-get pt 'rawdescription) "|" (substr station 1 (vl-string-search "." station))))

Jeff_M, also a frequent Swamper
EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report