I couldn't find what I'm looking for searching through the forums. If you know of something I've missed, please feel free to point me in the right direction, so I can do some leg work myself.
Platform Used: AutoCAD C3D 2009 Land Desktop Companion (LDC)
I already have a routine that gathers station/offset information from the project alignment (in plan view), which translates into the offset of a line object in the cross section (previously selected). The line object is a construction line drawn prior to the routine running, and centered on all cross sections.
I can programmatically select a cross section by point using this, as part of my larger routine:
Code:
(vl-load-com)
;; Extracted from CUI
(cd_mnl)
(zz_sdsk '(ad_xsutl 1)) ; Load ldd cmd,
(c:LDD) ; Select section by point.
What I need help doing programmatically is this:
1. Determine the station of the section selected (i.e., 586+00.00)
- I’ve determined that using LDD command to select by point, ENTLAST is not the xs_def2 block desired. Thus I cannot pull the station information from the ENTLAST entity name’s attribute data.
- Another issue identified, apparently the “Station” attribute data listed within the xs_def2 block does not match the listed current section. (i.e., you select station by point and the command line returns “Current Section 595+12.34,” whereas the station property of the xs_def2 block that is associated with said section reads “59511.231342”… no matchy.
- There’s got to be a way to extract the current section (i.e., current station) from the data base, no?
2. Once the current section has been stored to a local variable (in theory), I can determine the datum elevation (i.e., 15.00), and insertion point of the xs_def2 block itself:
Code:
(defun c:TEST (/ obj1 eName eData sectionStation sectionDatum
sectionInsert)
;| Using entsel here in lieu of the missing programmatic
selection mentioned above. |;
(setq obj1 (entsel))
;| Note - Relying on selection of this block is not a sustainable option,
as this block is only visible when “attmode” = 2.
Instead, I would like to create a selection set from the extracted
section value. (i.e., (ssget "x" '((1 . [ExtractedSectionValueHere])))
If there’s a better method, I am open to suggestions!!! |;
(setq eName (car obj1))
;| No idea why this does not work...?
It works on some of my other routines just fine.
(while
(and
(/= (cdr (assoc 0 eData)) "ATTRIB")
(/= (cdr (assoc 2 eData)) "STATION"))
(progn
(setq eName (entnext eName))
(setq eData (entget eName))))
Instead of returning the “Station” attdef, it returns the “Name”…?
(if
(= (cdr (assoc 0 eData)) "ATTRIB")
(setq sectionStation (cdr (assoc 1 eData)))) |;
(repeat 2
(setq eName (entnext eName))
(setq eData (entget eName)))
(if
(= (cdr (assoc 0 eData)) "ATTRIB")
(setq sectionStation (cdr (assoc 1 eData))))
(setq eName (car obj1))
(repeat 14
(setq eName (entnext eName))
(setq eData (entget eName)))
(if
(= (cdr (assoc 0 eData)) "ATTRIB")
(setq sectionDatum (cdr (assoc 1 eData))))
(setq sectionInsert (cdr (assoc 10 (entget (car obj1)))))
;; Display results
(prompt (strcat "\n Current Section = " sectionStation))
(prompt (strcat "\n Datum = " sectionDatum))
(prompt "\n Insertion = ")
(princ sectionInsert)
(princ)) ;_end defun
(c:TEST)
If someone can help me get passed this roadblock, I pretty much have a clear idea of what code is necessary to permit the user to enter the necessary pipe data, thus drawing the pipe in the section (horizontally), based on the datum, and insertion point of the xs_def2 block (polar calculations adjusted for section scale).
Once this is accomplished, I will make the attempt to proceed with prompting the user to specify a point within the profile (top of pipe, or invert), which may be used to then extract the vertical portion of this routine.
Also worthy of note - this routine is primarily being used to draw the existing utilities in the cross section, as these are not done using pipeworks (at least not at my company). It's faster just to draw them manually (even without the routine I am attempting here), I'm simply trying to automate the process already in use today. Currently, this task is usually done with the given that the user has three viewports: Cross Section, Plan, and Profile views.
Cheers!