Author Topic: MatchProps Profile View (Station and Elevation)  (Read 4791 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
MatchProps Profile View (Station and Elevation)
« on: July 10, 2023, 09:56:21 AM »
I was playing around with creating a routine that would allow you to change the profile view station and elevation rather than right clicking on the profile view and going through all the tabs.

I do have something together, however I am having a problem making the match properties of the command.

This will prompt the user to enter the values with a Start Station and End Station, with a Min Elevation and Max Elevation.

Code: [Select]
(defun C:PRS ( / StaS StaE ElevMin ElevMax )
(vl-load-com)
;;https://forums.autodesk.com/t5/civil-3d-customization/define-profile-view-station-and-elevation-ranges-via-lisp/td-p/9683823
;Unlocks ProfileView station and elevation inputs
(setq pvent (car (entsel)))
(setq pv (vlax-ename->vla-object pvent))
(if (= 0 (vlax-get pv 'elevationlocked))
  (vlax-put-property pv 'elevationlocked :vlax-false)
  )
(if (= 0 (vlax-get pv 'stationlocked))
  (vlax-put-property pv 'stationlocked :vlax-false)
  )

;(vlax-put pv 'elevationmin 902)
;(vlax-put pv 'elevationmax 928)
;(vlax-put pv 'StationStart -10)
;(vlax-put pv 'StationEnd 30)


(setq StaS (getreal "Enter Start Station: "))
(setq StaE (getreal "Enter End Station: "))
(setq ElevMin (getreal "Enter Min Elevation: "))
(setq ElevMax (getreal "Enter Max Elevation: "))

(vlax-put pv 'StationStart StaS)
(vlax-put pv 'StationEnd StaE)
(vlax-put pv 'elevationmin ElevMin)
(vlax-put pv 'elevationmax ElevMax)

(princ)
)

I am guessing i could use the
Code: [Select]
;(vlax-get pv 'elevationmin )
;(vlax-get pv 'elevationmax )
;(vlax-get pv 'StationStart )
;(vlax-get pv 'StationEnd )

Then use it as a vlax-put

Thanks for any pointers!
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: MatchProps Profile View (Station and Elevation)
« Reply #1 on: July 10, 2023, 12:16:52 PM »
For a MatchProperties type I can't think of a time I'd want to set the start/end stations of PVs to match another PV. The Min/Max elevations, sure, so that is what the following does:
Code - Auto/Visual Lisp: [Select]
  1. (defun C:MatchPVElevations (/ ss sourcePV pv ElevMin ElevMax)
  2.   (if (setq ss (ssget "_:S" '((0 . "AECC_PROFILE_VIEW"))))
  3.     (progn
  4.       (setq sourcePV (vlax-ename->vla-object (ssname ss 0))
  5.             minElev  (vlax-get sourcePV 'elevationmin)
  6.             maxElev  (vlax-get sourcePV 'elevationmax)
  7.       )
  8.       (while (setq ss (ssget "_:S" '((0 . "AECC_PROFILE_VIEW"))))
  9.         ;;https://forums.autodesk.com/t5/civil-3d-customization/define-profile-view-station-and-elevation-ranges-via-lisp/td-p/9683823
  10.                                         ;Unlocks ProfileView station and elevation inputs
  11.  
  12.         (setq pv (vlax-ename->vla-object (ssname ss 0)))
  13.         (if (= 0 (vlax-get pv 'elevationlocked))
  14.           (vlax-put-property pv 'elevationlocked :vlax-false)
  15.         )
  16.         (vlax-put pv 'elevationmin minElev)
  17.         (vlax-put pv 'elevationmax maxElev)
  18.       )
  19.     )
  20.   )
  21.   (princ)
  22. )
  23.  

If you do want the stations to match as well, that would be simple enough to add in.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: MatchProps Profile View (Station and Elevation)
« Reply #2 on: July 10, 2023, 12:23:53 PM »
Thanks Jeff. Opens up for some ideas and works great. Appreciate the help.
Civil3D 2020

ribarm

  • Gator
  • Posts: 3270
  • Marko Ribar, architect
Re: MatchProps Profile View (Station and Elevation)
« Reply #3 on: July 10, 2023, 01:32:03 PM »
@Jeff

Small remark :
(while (setq ss (ssget "_:S" '((0 . "AECC_PROFILE_VIEW"))))

should be :
(while (setq ss (ssget "_:S:L" '((0 . "AECC_PROFILE_VIEW"))))
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: MatchProps Profile View (Station and Elevation)
« Reply #4 on: July 10, 2023, 05:04:05 PM »
@ribarm, thanks! And after further review both ssget calls really should've been this: ssget "_:S+.:L"  (the :L not required for the first one)