MartinSomerville Posted April 19, 2010 Share Posted April 19, 2010 Hiya again, I am trying to get z-coord from a region so I can move it to the current ucs z=0 position. I thought I could do it by setting the ucs to object, the object being a region but for some reason I cannot do this with lisp. I can with the object command line and selecting the region with a mouse but not through (command "ucs" "object" ename) I love how acad allows you to do with mouse but not with lisp ..not So I looked to the acad entget data but there is nothing useful there that I can see.. Also in the vlisp data, there is no useful data there either.. unless you are in the ucs of the region.. a. Dumps a selected entity vl properties and methods b. Sets the object as variable o-e Select Entity to display Visual Lisp Properties and methods: ; IAcadRegion: AutoCAD Region Interface ; Property values: ; Application (RO) = #<VLA-OBJECT IAcadApplication 00d591b4> ; Area (RO) = 470.411 ; Centroid (RO) = AutoCAD.Application: Region is not on the UCS plane ; Document (RO) = #<VLA-OBJECT IAcadDocument 0159dfa8> ; Handle (RO) = "2934" ; HasExtensionDictionary (RO) = 0 ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0e541ddc> ; Layer = "0" ; Linetype = "BYLAYER" ; LinetypeScale = 1.0 ; Lineweight = -1 ; Material = "ByLayer" ; MomentOfInertia (RO) = AutoCAD.Application: Region is not on the UCS plane ; Normal (RO) = (-2.54156e-031 -7.36711e-047 1.0) ; ObjectID (RO) = 2125886304 ; ObjectName (RO) = "AcDbRegion" ; OwnerID (RO) = 2126130360 ; Perimeter (RO) = 93.132 ; PlotStyleName = "ByLayer" ; PrincipalDirections (RO) = AutoCAD.Application: Region is not on the UCS plane ; PrincipalMoments (RO) = AutoCAD.Application: Region is not on the UCS plane ; ProductOfInertia (RO) = AutoCAD.Application: Region is not on the UCS plane ; RadiiOfGyration (RO) = AutoCAD.Application: Region is not on the UCS plane ; TrueColor = #<VLA-OBJECT IAcadAcCmColor 0bf69380> ; Visible = -1 ; Methods supported: ; ArrayPolar (3) ; ArrayRectangular (6) ; Boolean (2) ; Copy () ; Delete () ; Explode () ; GetBoundingBox (2) ; GetExtensionDictionary () ; GetXData (3) ; Highlight (1) ; IntersectWith (2) ; Mirror (2) ; Mirrortextscr Command: 3D (3) ; Move (2) ; Rotate (2) ; Rotate3D (3) ; ScaleEntity (2) ; SetXData (2) ; TransformBy (1) ; Update () so..... I know it can be done because the mouse can click to the ucs of the region (actually on further clicking - it is clicking to ucs of the object that made the region).. so I guess i need to access an entity inside the region.. which I can't think of how to do.. unless I copy the region on itself, explode the copy then get data from the last created item ?? but then I'll have extra lines and circles which I don't know how to get rid of.. unless I do an entity count before and after I create the copy and explode.. which I'm not exactly sure how to do either.. (actually yeah I might but I'm wondering if it will take a long time - could I create a selection set before then create a selection set after and subtract the latter from former and delete.. ha this is getting complicated.. anyone know how to get some point data from a region? I am probably looking at it from the wrong way thanks martin Quote Link to comment Share on other sites More sharing options...
SEANT Posted April 19, 2010 Share Posted April 19, 2010 I’ve wrangle quite a bit with this type of task from the VBA end. I have to assume it would be similar to the ActiveX/com VisualLisp hook. Exploding the region is a viable option, though you may not have to copy the region first. At least you don’t with VBA; the original object stays intact and the function (method) returns an array of AutoCAD entities that are copies of those that made up the Region. Any one of the entities can be queried for a point location, and then the array can be iterated to erase everything afterwards. Of course, the point that was queried would only be immediately useful if the region is parallel to XY of the WCS. If the region’s Normal is anything other than 0,0,1 (or some reasonable facsimile - such as was posted in your entget data) then additional transformations/translations would be required. Quote Link to comment Share on other sites More sharing options...
MartinSomerville Posted April 19, 2010 Author Share Posted April 19, 2010 thanks sean, yeah the region would be parallel but in different z typically.. not up with vba at all (started to learn it - vb.net - but have to get back to it one day) so I might have a play with vlisp to see what data it gives when I explode... etc thanks for your help Quote Link to comment Share on other sites More sharing options...
MartinSomerville Posted April 20, 2010 Author Share Posted April 20, 2010 vlisp works the same way as you suggested... it creates a varient which has a list of entities that make up the region and yeah explode works differently to acad lisp in that it leaves the original as you said.. haven't finished it yet but yeah I think this'll be the best way to go. cheers Quote Link to comment Share on other sites More sharing options...
wizman Posted April 20, 2010 Share Posted April 20, 2010 Since it's parallel and Normal (RO) = (-2.54156e-031 -7.36711e-047 1.0) is almost same with '(0 0 1) would this not work? (vla-getboundingbox (vlax-ename->vla-object (car (entsel))) 'll 'up) (last(vlax-safearray->list up)) Quote Link to comment Share on other sites More sharing options...
MartinSomerville Posted April 20, 2010 Author Share Posted April 20, 2010 sure does I got the program working the other way anyway Ha. I'm not very strong with vlisp - only use it when autolisp slower or harder. I was never sure how to use the boundingbox but now I do thanks.. I never knew what to put in the 'minpoint and 'maxpoint. I guess the outpot only should have given me a clue.. So i can put anything there and the min/max points will be assigned to the variable names I choose as safe arrays. I think i get it anyway.. but the dash (') i'm sure about. It seems to work without it.. am sure I'm missing something here.. anyway.. thanks again all cheers martin Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2010 Share Posted April 20, 2010 The 'dash' (or apostrophe) means that the symbol will be taken as an argument for the function and not evaluated. If the apostrophe were not present the function would be evaluated: (vla-getBoundingBox <obj> nil nil) More on the apostrophe here: http://www.cadtutor.net/forum/showpost.php?p=258390&postcount=20 Quote Link to comment Share on other sites More sharing options...
MartinSomerville Posted April 20, 2010 Author Share Posted April 20, 2010 thanks lee.. i think that will explain a few things once I get my head around it. i often had grief with it with ssget filters.. I think I get why my apostophes didn't work in those situation now ...maybe Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2010 Share Posted April 20, 2010 Happy I could be of help Quote Link to comment Share on other sites More sharing options...
mtahir2003pk Posted July 25, 2010 Share Posted July 25, 2010 this is lisp to find region cg i want to move my ucs on cg and then from cg i need mass properties into drawing any one know about or help me.. Thanks RCG.lsp 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.