jschlichter Posted January 26, 2011 Share Posted January 26, 2011 Hi, I'm fairly new to writing with autolisp and am having a bit of an issue. I'm attempting to write a pipe program that labels the invert of a pipe at a specific point. Since I'm fairly new to coding I find using the functions easier than working with dxf codes for civil 3d objects. Using the above activex method on my pipe gives me the property 'startpoint. This is apparently another activex object, however I am not able to use method on it to list its x, and y coordinates (which I would like to be able to use further in the program). I'm assuming that it's a 3d point but still don't know how to access the individual coordinates. Any experts out there who can help me out with this? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 26, 2011 Share Posted January 26, 2011 Welcome to the forums! Perhaps using one of these two options would suite your needs.... Option 1: (vlax-safearray->list (vlax-variant-value (vla-get-startpoint [i][color=red]obj[/color][/i]))) Options 2: (vlax-get [i][color=#ff0000]obj [/color][/i]'startpoint) Quote Link to comment Share on other sites More sharing options...
jschlichter Posted February 7, 2011 Author Share Posted February 7, 2011 Thanks for the response. That's sort of what I was expecting to get when using the (vlax-get-property 'startpoint) for the pipe (a 3d point list). However, for some reason when used on the pipe object, instead of returning a list (which would be awesome because I could use the car/cdr functions) it returns a VLA object name. Attempting to access this objects name with (vlax-dump-object) returns an error. I would somehow like to access it as a list but don't know where to go from here. Is it perhaps that it's just because it's a Civil 3D object? Again, my code worked fine in 2008 but apparently this "startpoint" object no longer has 'x and 'y properties. Using the vlax safe array code [(vlax-safearray->list (vlax-variant-value (vla-get-startpoint Obj)))] on the pipe returned this error [; error: bad argument type: variantp #] however, it returned a point list for a regular autocad arc. I'm confused. Here's what I get for the dump on the pipe: Command: (vlax-dump-object obj t) ; IAeccPipe: Pipe interface ; Property values: ; Alignment = nil ; Application (RO) = #<VLA-OBJECT IAeccApplication 18021a90> ; ClosestPointTo (RO) = ...Indexed contents not shown... ; Connectors (RO) = #<VLA-OBJECT IAeccConnectors 18021e50> ; Description = "300 mm Concrete" ; DisplayName (RO) = "Pipe - (265)" ; Document (RO) = #<VLA-OBJECT IAeccDocument 185ec5e0> ; EGLDown = 0.0 ; EGLUp = 0.0 ; EndPoint (RO) = #<VLA-OBJECT 185ec540> ; EndStructure (RO) = #<VLA-OBJECT IAeccStructure 28b2c440> ; FlowDirection (RO) = 1 ; FlowDirectionMethod = 1 ; Handle (RO) = "7ACC8" ; HasExtensionDictionary (RO) = 0 ; HGLDown = 0.0 ; HGLUp = 0.0 ; HoldOnResize = 0 ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 296c117c> ; InnerDiameterOrWidth (RO) = 0.3 ; InnerHeight (RO) = 0.3 ; IsMaxCoverViolated (RO) = ...Indexed contents not shown... ; IsMinCoverViolated (RO) = ...Indexed contents not shown... ; Labels (RO) = #<VLA-OBJECT IAeccPipeLabels 18a97600> ; Layer = "N-STM" ; Length2D (RO) = 57.8195 ; Length3D (RO) = 57.8918 ; Linetype = "ByLayer" ; LinetypeScale = 1.0 ; Lineweight = -1 ; Material = "ByLayer" ; MaximumCover (RO) = 0.0 ; MinimumCover (RO) = 0.0 ; Name = "Pipe - (265)" ; ObjectID (RO) = 2129999104 ; ObjectName (RO) = "AeccDbPipe" ; OuterDiameterOrWidth (RO) = 0.44 ; OuterHeight (RO) = 0.44 ; OwnerID (RO) = 2129857784 ; ParamsBool (RO) = #<VLA-OBJECT 185ec760> ; ParamsDouble (RO) = #<VLA-OBJECT 185ec4c0> ; ParamsLong (RO) = #<VLA-OBJECT 185ec280> ; ParamsString (RO) = #<VLA-OBJECT 185ec020> ; PartDataRecord = #<VLA-OBJECT IAeccPartDataRecord 18025138> ; PartFamily (RO) = #<VLA-OBJECT IAeccPartFamily 182ba398> ; PartSizeName (RO) = "300 mm Concrete Pipe" ; PartType (RO) = 10 ; PlotStyleName = "ByLayer" ; PointAtParam (RO) = ...Indexed contents not shown... ; Position (RO) = #<VLA-OBJECT IAeccPoint3d 185ec7e0> ; ProfileNetworkParts (RO) = #<VLA-OBJECT IAeccGraphProfileNetworkParts ;18a94a50> ; Radius (RO) = 0.0 ; ShowToolTip = -1 ; Slope (RO) = -0.05 ; StartPoint (RO) = #<VLA-OBJECT 185ec520> ; StartStructure (RO) = #<VLA-OBJECT IAeccStructure 28b2c640> ; STMPipeMetadata = unsupported result type: 65 ; Style = #<VLA-OBJECT IAeccPipeStyle 182ba3e8> ; SubEntityType (RO) = 0 ; Surface = nil ; SweptShape (RO) = 2 ; TrueColor = #<VLA-OBJECT IAcadAcCmColor 18a97a20> ; Visible = -1 ; WallThickness (RO) = 0.07 ; Methods supported: ; ArrayPolar (3) ; ArrayRectangular (6) ; ConnectToPipe (3) ; ConnectToStructure (2) ; Copy () ; Delete () ; Disconnect (1) ; GetBoundingBox (2) ; GetExtensionDictionary () ; GetXData (3) ; Highlight (1) ; IntersectWith (2) ; IsReferenceObject () ; IsReferenceStale () ; IsReferenceSubObject () ; IsReferenceValid () ; Mirror (2) ; Mirror3D (3) ; Move (2) ; Project2dPointVertically (1) ; ResizeByInnerDiaOrWidth (3) ; Rotate (2) ; Rotate3D (3) ; ScaleEntity (2) ; SetStartAndEndPoints (2) ; SetXData (2) ; SwapPartFamilyAndSize (2) ; TransformBy (1) ; Update () It says that the startpoint property is another VLA object, but I don't know where to go from there as it doesn't support the object dump itself. Quote Link to comment Share on other sites More sharing options...
Smirnoff Posted February 7, 2011 Share Posted February 7, 2011 Please get StartPoint object to variable: (setq StartPointObj (vla-get-StartPoint (vlax-ename->vla-object(car(entsel))))) and show to us prpoerties and methods for this object not for pipe: (vlax-dump-object StartPointObj T) Quote Link to comment Share on other sites More sharing options...
jschlichter Posted February 7, 2011 Author Share Posted February 7, 2011 That's the issue I'm having. Autocad will not let me dump the startpoint. In Civil 2008 it seemed to work fine. It is only since changing to 2010 that I've been having this issue. Quote Link to comment Share on other sites More sharing options...
Smirnoff Posted February 7, 2011 Share Posted February 7, 2011 Using the vlax safe array code [(vlax-safearray->list (vlax-variant-value (vla-get-startpoint Obj)))] on the pipe returned this error[; error: bad argument type: variantp #] however, it returned a point list for a regular autocad arc. It seems you don't understood me. Now StartPoint not property but object. Pick pipe with my code, then make dump for StartPointObj variable not for pipe. Or I do not understand you Quote Link to comment Share on other sites More sharing options...
BlackBox Posted February 7, 2011 Share Posted February 7, 2011 That's the issue I'm having. Autocad will not let me dump the startpoint. In Civil 2008 it seemed to work fine. It is only since changing to 2010 that I've been having this issue. Perhaps if you were more specific... What does AutoCAD display at the commend line, when it 'will not let [you] dump the startpoint'? Have you loaded (vl-load-com)? Failing to do so, would prevent Smirnoff's code from working. Quote Link to comment Share on other sites More sharing options...
jschlichter Posted February 7, 2011 Author Share Posted February 7, 2011 Using Smirnoff's code !startpointobj #<VLA-OBJECT 18c9e848> This is the same result I've been getting from using the ...get-startpoint code The following error is returned: Command: (vlax-dump-object starpointobj t) ; error: bad argument type: VLA-OBJECT nil Yes, (vl-load-com) is the first line in the lisp. Thanks for the help guys, I'm thoroughly confused. Quote Link to comment Share on other sites More sharing options...
jschlichter Posted February 7, 2011 Author Share Posted February 7, 2011 Sorry, just realize my typo this is the actual error: Command: (vlax-dump-object startpointobj t) ; Object does not support ITypeInfo interface Quote Link to comment Share on other sites More sharing options...
Smirnoff Posted February 7, 2011 Share Posted February 7, 2011 Understand. We must try to act blind. For first try to retrieve from StartPointObj some common property for ex. OwnerID (vlax-get-property StartPointObj 'OwnerID) If this is successfully. Try to find the secret property for example: (vlax-get-property StartPointObj 'Coordinate) (vlax-get-property StartPointObj 'Coordinates) (vlax-get-property StartPointObj 'Point) Etc... If not success. Throw it dirty business and go drink beer... Quote Link to comment Share on other sites More sharing options...
jschlichter Posted February 7, 2011 Author Share Posted February 7, 2011 No such luck Command: (vlax-get-property StartPointObj 'OwnerID) ; error: ActiveX Server returned an error: Element not found I like plan B though.... Quote Link to comment Share on other sites More sharing options...
alanjt Posted February 7, 2011 Share Posted February 7, 2011 It's just not accessible through LISP. A lot of properties aren't accessible or nearly impossible to access through the language. Quote Link to comment Share on other sites More sharing options...
Smirnoff Posted February 7, 2011 Share Posted February 7, 2011 May be there is plan C which starts with: (vla-getInterfaceObject "bla bla bla.18") I don't know how "bla bla bla" for Civil 3D 2010. Quote Link to comment Share on other sites More sharing options...
jschlichter Posted February 7, 2011 Author Share Posted February 7, 2011 Me either unfortunately. Maybe it's time I started learning VBA or .net. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted February 7, 2011 Share Posted February 7, 2011 It's just not accessible through LISP. A lot of properties aren't accessible or nearly impossible to access through the language. Does this mean stepping up into one of the .NET flavors (i.e., C#, VB, etc.)...? Edit: Perhaps I've answered my own question (screenshot from Visual Basic Express 2010) - Quote Link to comment Share on other sites More sharing options...
Hippe013 Posted July 27, 2014 Share Posted July 27, 2014 First off. I realize that this post is old. I have been struggling with this issue for quite some time. In my research I have come across this thread. I figured I'd shed some light. Accessing pipes and structures is not straight forward by any means. One would tend to think that to get the startpoint of the pipe you'd use code as listed above. The object retrieved from that is a Point3D object causes headaches and errors when trying get the X Y Z. To read the start and end points use the following: (setq p0 (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam 0)))) or (setq p1 (vlax-safearray->list (vlax-variant-value (vlax-get-property pipe 'PointAtParam 1)))) To set the start and end points you can use the following: (vlax-invoke-method pipe 'SetStartandEndPoints pnt1 pnt2) Where pnt1 and pnt2 are converted using (vlax-3d-point) The center of structure is an IAeccPoint object and has its own methods of setting and getting the X Y Z. I hope that this sheds some light on the issue of accessing Civil 3D Pipes and Structures. I would love to discuss this more if people are interested. regards, hippe013 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 28, 2014 Share Posted July 28, 2014 If you just want a invert level then here use this. Just have a text at the point for lable. Pick datum level, datum line, then pt, then text for answer, multiple supported. ;Calculates level of a point in cross or long sections (setvar "cmdecho" 0) (princ "\n To run just type SRL") ;;-------------------=={ Parse Numbers }==--------------------;;` ;; ;; ;; Parses a list of numerical values from a supplied string. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url] ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; s - String to process ;; ;;------------------------------------------------------------;; ;; Returns: List of numerical values found in string. ;; ;;------------------------------------------------------------;; (defun LM:ParseNumbers ( s ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (mapcar (function (lambda ( a b c ) (if (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) b 32 ) ) ) (cons nil l) l (append (cdr l) (list nil)) ) ) ")" ) ) ) (vl-string->list s) ) ) (defun c:SRL () (setq olddimzin (getvar "dimzin")) (setvar "dimzin" 0) (if (= dwgscale nil) (setq dwgscale (/ 1000.0 (getreal "\n enter vertical scale "))) ) ;(setq datum (getreal "\n Enter datum level ")) (setq datum (car (LM:ParseNumbers (cdr (assoc 1 (entget (car (entsel "\nPick datum text")))))))) (setq test 1) (setq pt1 (cadr (getpoint "\npick datum"))) (while (= test 1) (setq pt2 (cadr (getpoint "\npick point"))) (setq dist (/(abs (- pt1 pt2)) dwgscale)) (setq en1 (car (entsel "\nSelect text number:" ))) (if (/= en1 nil) (progn (setq tent (entget en1)) (setq a (+ dist datum)) (setq a (rtos a 2 3)) (setq el (subst (cons 1 a) (assoc 1 tent) tent)) (entmod el) );progn (princ "\nplease pick again"); else );if ); while t (setq el nil en nil a nil en1 nil test nil) (setvar "cmdecho" 1) (setvar "dimzin" olddimzin) (princ) ) ;ends main defun Quote Link to comment Share on other sites More sharing options...
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.