Jump to content

XDATA - Elec Conduits, Cable & Equipment


nimble87

Recommended Posts

Hi All,

 

After months of playing around (pulling my hair out), I'm finally posting my question because I'm stumped at where to go with this. My lisp skills are a work in progress and are a product or scanning the forum pages over the years.

 

I'm an electrical designer who mainly works with underground HV and LV networks. I'm trying to streamline the way I draft my designs with a lisp capable of exporting my data to populate schedules and such.

 

A standard design consists of (A) electrical pillars (dynamic blocks with attributes and visibility states for pillar type), (B) conduit route between pillars (polyline), © a trench detail block (visibility states to determine the conduit arrangement) and (D) a cable block (visibility states determining the cable type).

 

attachment.php?attachmentid=59049&cid=1&stc=1

 

This is a breakdown of the lisp I've been imagining in my head :unsure::

 

  • Select starting pillar/equipment (A) - Lisp to note the pillars station number attribute and visibility state.
  • Select end pillar/equipment (A) - Same as above.
  • Select trench route between the above mentioned pillars (B) - Pick the conduit polyline.
  • Select trench detail © - Lisp to note the trench details current visibility state.
  • Select cable - Lisp to note the selected cables visibility state.

From all of the reading I've done I think the best way is to write all of the gathered information to the conduit/polyline using Xdata. Essentially the conduit polyline Xdata will have the start/end pillar station number, the conduit arrangement and the cable detail. After the Xdata has been written to each conduit/polyline I'd like to be able to export all to a spreadsheet along with the length of each polyline.

 

 

The following link is probably the closest I've found to what I need, it gave me some issues in exporting and I wasn't quite sure how the data was written.

http://www.cadtutor.net/forum/showthread.php?31153-adding-data-to-polyline-and-extracting-this-data-to-table

 

 

 

I've attached a file containing the standard blocks I use.

 

If anyone could assist I'd be extremely grateful as you'll be saving me from many many grey hairs!

 

many thanks in advance!

 

AJ

Sample.JPG

Sample.dwg

Link to comment
Share on other sites

If you look at the asmi code the 1st post it is almost what you want, you need to do 1 step at a time rather than do 1 big program and get totally lost.

 

Select a block and get attribute details

Select a block and get attribute details

Select pline as per asmi

Select block get att settings look at dump below shows how many variables are attached to a atribute

 

;This may be helpfull to add to asmi code

(setq len (vla-get-length plobj)) ; length of pline

(setq stbl (vlax-ename->vla-object (car (entsel "\nSelect 'Begin' block > "))))
(setq atts1 '())
(foreach att (vlax-invoke stbl 'getattributes)
(setq atts1 (cons (vla-get-textstring att) atts1)) ; make a list of attributes textstring is value of attribute
)

 

; note visibility and visible
(foreach att (vlax-invoke stbl 'getattributes)  (vlax-Dump-Object att) )
; IAcadAttributeReference: AutoCAD Attribute Reference Interface
; Property values:
;   Alignment = 10
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff61bf53318>
;   Backward = 0
;   Constant (RO) = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 00000000303ae0c8>
;   EntityTransparency = "ByLayer"
;   FieldLength = 0
;   Handle (RO) = "1FE"
;   HasExtensionDictionary (RO) = 0
;   Height = 2.0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0000000038659948>
;   InsertionPoint = (275.914 179.372 -999.0)
;   Invisible = 0
;   Layer = "0 PE Stations"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   LockPosition (RO) = -1
;   Material = "ByLayer"
;   MTextAttribute = 0
;   MTextAttributeContent = ""
;   MTextBoundaryWidth = 0.0
;   MTextDrawingDirection = 5
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 49
;   ObjectID32 (RO) = 49
;   ObjectName (RO) = "AcDbAttribute"
;   ObliqueAngle = 0.0
;   OwnerID (RO) = 46
;   OwnerID32 (RO) = 46
;   PlotStyleName = "Color_7"
;   Rotation = 0.0
;   ScaleFactor = 1.0
;   StyleName = "Standard"
;   TagString = "STN"
;   TextAlignmentPoint = (277.248 180.372 -999.0)
;   TextGenerationFlag = 0
;   TextString = "S1"
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 00000000386594c0>
;   UpsideDown = 0
;   Visible = -1

Link to comment
Share on other sites

Thanks so much for taking the time to reply Al. This has given me my next stepping stone towards my goal, I'll see what I can piece together when I get the time and post back with an update (more questions). Cheers

Link to comment
Share on other sites

I've cut everything back and tried to simplify it as much as I can, for now i'm working with the alert box to display my results (will add export capabilities later).

 

The polyline length is giving me some issues, I can't get it to add to the list and then show in the alert box. The next issue is getting the attribute settings, I tried to incorporate the suggestion from BIGAL but keep getting "AutoCAD variable setting rejected: "OSMODE" nil". For now i've got it set to return the handles of each item, I'd like to get this to show the start and end block attribute "STN" and the trench detail visibility state (or an attribute that has the visibility state as a field, which ever is easiest)

 

Any comments would be greatly appreciated.

 

Cheers.

 

(defun c:TESTW(/ plObj stBl enBl tren len datLst)
 (vl-load-com)
 (if
   (and
       (setq plObj(vlax-ename->vla-object (car (entsel "\nSelect trench to write > "))))
       (setq stBl(entsel "\nSelect 'start' block > "))
       (setq enBl(entsel "\nSelect 'end' block > "))
       (setq tren(entsel "\nSelect trench detail > "))
   ); end and

   (progn
     (setq
     len (vla-get-length plObj)
     stBl(cdr(assoc 5(entget(car stBl))))
     enBl(cdr(assoc 5(entget(car enBl))))
     tren(cdr(assoc 5(entget(car tren))))
     datLst(list(cons 1 stBl)(cons 2 enBl)(cons 3 tren)
     ;(cons 4 len)
     )
     ); end setq
   (vlax-ldata-put plObj "Trench Data" datLst)
   ); end progn
  );end if
 (princ)
 ); c:TESTW
 

(defun c:TESTR(/ rObj datLst)
 (vl-load-com)
 (if(and
      (setq rObj(entsel "\nSelect trench to read > "))
      (setq datLst(vlax-ldata-get(car rObj) "Trench Data"))
      ); and
   (alert(strcat "Start block: "(cdr(assoc 1 datLst))
                 "\n\nEnd block: "(cdr(assoc 2 datLst))
                 "\n\nTrench detail: "(cdr(assoc 3 datLst))
                 "\n\nLength: can't get length here?" ))
   (alert "\nNo data found. ")
   ); end if
 (princ)
 ); end of c:TESTR

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...