toberino Posted April 2, 2012 Posted April 2, 2012 Hey all, its been a while but I'm back and need some help. I am trying to find a lisp that will insert a specified block at a specified point layer. Example: I have 385 points for tree locations on a layer named "TREE". I have a tree block that I would like to insert on all of the tree points. No scaling or rotating needed. I have over 6000 points of all different layers and names so the nodesert routine does not work because it inserts the block onto every point in the drawing. I want it to only insert onto a specified layer. Does anyone know of a routine that could fit my needs? I hope I kinda got my point across. Thank for the help. Nate Quote
ReMark Posted April 2, 2012 Posted April 2, 2012 How are these "tree points" identified in the drawing? Quote
BIGAL Posted April 3, 2012 Posted April 3, 2012 Do you have all the points as a CSV or excel then if there something like 1,121.456,789.102,tree its pretty easy and the chances are that a lisp already exists checkout Lee Mac's import points routine may do what you want. If CSV paste a few lines here or if excell paste as text its a question that has been asked lots of times. watch this space as well http://www.cadtutor.net/forum/showthread.php?67934-Need-lisp-to-draw-circles-from-coordinates/page3 Quote
Tharwat Posted April 3, 2012 Posted April 3, 2012 I am trying to find a lisp that will insert a specified block at a specified point layer.Example: I have 385 points for tree locations on a layer named "TREE". I have a tree block that I would like to insert on all of the tree points. No scaling or rotating needed. This would help you for the 385 points (defun c:test (/ found ss i sn) (if (and (setq found (tblsearch "BLOCK" "TREE")) (setq ss (ssget "_:L" '((0 . "POINT") (8 . "TREE")))) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (entmake (list '(0 . "INSERT") '(2 . "TREE") (assoc 10 (entget sn)) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) '(50 . 0.) ) ) ) (cond ((not found) (alert " Block < TREE > not found ! ")) (t (alert " Please select points on TREE layer ...") ) ) ) (princ) ) . I have over 6000 points of all different layers and names so the nodesert routine does not work because it inserts the block onto every point in the drawing. I want it to only insert onto a specified layer.Does anyone know of a routine that could fit my needs? So what is the name of the block to be inserted on the 6000 points on that different layers ? Quote
irneb Posted April 3, 2012 Posted April 3, 2012 So you've got the points on the drawing already (6000 of them), but you only want to place your block on those points on a specified layer? Have you looked at isolating that layer (LAYISO command). Then something like this might help: (defun c:InsertToPoints (/ blkName ss space doc) (setq blkName "MyBlock") ;Change to your requirements (if (and (ssget '((0 . "POINT"))) (setq ss (vla-get-ActiveSelectionSet (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))) (setq space (vla-ObjectIdToObject doc (vla-get-OwnerID (vla-Item ss 0))))) (progn (vlax-for obj ss (vla-InsertBlock space (vla-get-Coordinates obj) blkName 1.0 1.0 1.0 0.0)) (vla-Delete ss))) (princ)) If you want to see all layers, then a filter might help. Try the Filter command or even QSelect to only select points on one or more specified layers, then run the lisp above. Or modify the lisp to add such filter into its ssget call, something like this: (ssget (list '(0 . "POINT") (cons 8 "LayerName"))) Quote
toberino Posted April 3, 2012 Author Posted April 3, 2012 How are these "tree points" identified in the drawing? Points or nodes. x,y,z coordinates with the z coord removed before being xref'd. Do you have all the points as a CSV or excel then if there something like 1,121.456,789.102,tree its pretty easy and the chances are that a lisp already exists checkout Lee Mac's import points routine may do what you want. If CSV paste a few lines here or if excell paste as text its a question that has been asked lots of times. watch this space as well http://www.cadtutor.net/forum/showthread.php?67934-Need-lisp-to-draw-circles-from-coordinates/page3 They are not generated as a csv. They are exported to a .dxf from a .cor then inserted as an exploded block. (the only way to get the units and scale correct going from metric to imperial. It's long story...) This would help you for the 385 points (defun c:test (/ found ss i sn) (if (and (setq found (tblsearch "BLOCK" "TREE")) (setq ss (ssget "_:L" '((0 . "POINT") (8 . "TREE")))) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (entmake (list '(0 . "INSERT") '(2 . "TREE") (assoc 10 (entget sn)) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) '(50 . 0.) ) ) ) (cond ((not found) (alert " Block < TREE > not found ! ")) (t (alert " Please select points on TREE layer ...") ) ) ) (princ) ) So what is the name of the block to be inserted on the 6000 points on that different layers ? They are all different. About 1000 of them are sanitary, storm and inlet grates blocks, and most of them are connecting the dots for curbs and sidewalks. So you've got the points on the drawing already (6000 of them), but you only want to place your block on those points on a specified layer? Have you looked at isolating that layer (LAYISO command). Then something like this might help:(defun c:InsertToPoints (/ blkName ss space doc) (setq blkName "MyBlock") ;Change to your requirements (if (and (ssget '((0 . "POINT"))) (setq ss (vla-get-ActiveSelectionSet (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))) (setq space (vla-ObjectIdToObject doc (vla-get-OwnerID (vla-Item ss 0))))) (progn (vlax-for obj ss (vla-InsertBlock space (vla-get-Coordinates obj) blkName 1.0 1.0 1.0 0.0)) (vla-Delete ss))) (princ)) If you want to see all layers, then a filter might help. Try the Filter command or even QSelect to only select points on one or more specified layers, then run the lisp above. Or modify the lisp to add such filter into its ssget call, something like this: (ssget (list '(0 . "POINT") (cons 8 "LayerName"))) Many, many thanks to all of your responses. I am going to test these out now to see if they will work for what I am trying to do. Quote
Lee Mac Posted April 3, 2012 Posted April 3, 2012 Haven't properly read the entire thread, but this may help you also: http://lee-mac.com/ptmanager.html Quote
toberino Posted April 3, 2012 Author Posted April 3, 2012 So you've got the points on the drawing already (6000 of them), but you only want to place your block on those points on a specified layer? Have you looked at isolating that layer (LAYISO command). Then something like this might help:(defun c:InsertToPoints (/ blkName ss space doc) (setq blkName "MyBlock") ;Change to your requirements (if (and (ssget '((0 . "POINT"))) (setq ss (vla-get-ActiveSelectionSet (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))) (setq space (vla-ObjectIdToObject doc (vla-get-OwnerID (vla-Item ss 0))))) (progn (vlax-for obj ss (vla-InsertBlock space (vla-get-Coordinates obj) blkName 1.0 1.0 1.0 0.0)) (vla-Delete ss))) (princ)) If you want to see all layers, then a filter might help. Try the Filter command or even QSelect to only select points on one or more specified layers, then run the lisp above. Or modify the lisp to add such filter into its ssget call, something like this: (ssget (list '(0 . "POINT") (cons 8 "LayerName"))) My first idea was to turn off and freeze all layers except the "TREE" layer which is essentially the same thing as isolating the layer, I believe, please correct meif I'm wrong, and then use the nodesert lisp but it still sees all of the points and puts a tree block on all of my points in the drawing, even if they are off and frozen. Utilizing quick select is an exellent tool and I can select all of the tree points, but I have not found the right combination to insert the block on only the tree points. Spending a few hours to get a routine that works for this situation will save me so many hours of inserting the same block over and over and over again, so I will continue to experment until I find an answer. The lisp's posted so far are isolating it to my "tree Block". Is there a way to give me the choice for the block and for the layer??? Quote
toberino Posted April 3, 2012 Author Posted April 3, 2012 Haven't properly read the entire thread, but this may help you also: http://lee-mac.com/ptmanager.html Very good routine Lee Mac. This is exactly what I needed. 1. quick select to select all 385 tree points 2. ptm enter to invoke lisp routine 3. click >> input type to select all selected points 4. select block 5. click ok Boom....!!!! Huge thanks for this.... Quote
Lee Mac Posted April 3, 2012 Posted April 3, 2012 Very good routine Lee Mac. This is exactly what I needed.1. quick select to select all 385 tree points 2. ptm enter to invoke lisp routine 3. click >> input type to select all selected points 4. select block 5. click ok Boom....!!!! Huge thanks for this.... You're very welcome toberino That program is actually one of my much older programs and the source code probably needs a complete overhaul, but I'm glad its still proving useful all these years later. Quote
BIGAL Posted April 4, 2012 Posted April 4, 2012 Whats a .COR is this some type of data recorder file if so what brand. Quote
SLW210 Posted April 4, 2012 Posted April 4, 2012 Whats a .COR is this some type of data recorder file if so what brand. Trimble GIS Quote
toberino Posted April 4, 2012 Author Posted April 4, 2012 Trimble GIS That is correct. We use a Trimble Geo to collect Gps points (x,y,z and lat and long). To go a little deeper, the geo collects and stores them as an .ssf file. Then we correct the .ssf file with a program called GPS Pathfinder Office based off of the most local base providers information to correct for velocity and real time position. This is where we get the .cor file....cor....cor....rected. Then we can combine all of our .cor and export to a .dxf to be imported to CAD. Quote
BIGAL Posted April 5, 2012 Posted April 5, 2012 Understand now the dxf is a lines and points output what you need is the next level up take the cor and string the points, assign breaklines based on code, add blocks to points at correct scale/orientation then hit make surface. I would expect that Trimble have this option available Field to complete dwg you may want to contact your local dealer, check first CIV3D for Trimble options. Some else here who uses Trimble may be able to help. (ex Topcon dealer) Quote
irneb Posted April 5, 2012 Posted April 5, 2012 ...The lisp's posted so far are isolating it to my "tree Block". Is there a way to give me the choice for the block and for the layer???Would the layer/blockname change every time you use the lisp? Otherwise you could simply modify the lisp to use the correct layer and/or block name instead - simple search & replace would do. Otherwise you'd need some other way to obtain the Layer/BlockName from the user. Say by picking an example object, or opening a dialog listing the layers and asking to select one. Quote
toberino Posted April 5, 2012 Author Posted April 5, 2012 Understand now the dxf is a lines and points output what you need is the next level up take the cor and string the points, assign breaklines based on code, add blocks to points at correct scale/orientation then hit make surface. I would expect that Trimble have this option available Field to complete dwg you may want to contact your local dealer, check first CIV3D for Trimble options. Some else here who uses Trimble may be able to help. (ex Topcon dealer) If there was a way to automate stringing the points together I would love to hear about it. A fully automated process would reduce so much time. Would the layer/blockname change every time you use the lisp? Otherwise you could simply modify the lisp to use the correct layer and/or block name instead - simple search & replace would do. Otherwise you'd need some other way to obtain the Layer/BlockName from the user. Say by picking an example object, or opening a dialog listing the layers and asking to select one. All of the block names and point names and layers would always be the same. Lee Mac's point manager is the tool that I was looking for. I am excited to see how else I can use it, since that is what I do, is, manage points. huh, I've never looked at it that way before. I very much appreciate all of the help I have recieved from this site. I know that when I get one of those hair brain ideas that may or may not even be possible I can come here to work through the possibilities of making it happen. Props to all of you regulars for being there for me. Quote
BIGAL Posted April 8, 2012 Posted April 8, 2012 The stringing concept has been around for 30+ years just not in Autocad, Field straight to complete picture with very little tidying up. The use of codes to either string points together be a symbol or lots of smart coding 001201*001202 means join string 1 to string 2 at this point stuff like offset point what point is contourable v's not. Check out Stringer at www.civilsurveysolutions.com.au Quote
godofcad Posted April 10, 2012 Posted April 10, 2012 Try This Code ;;Main Function ........................ (Defun c:insb () (setq osm (getvar "OSMODE")) (setq old (getvar "clayer")) (setvar "OSMODE" 0) (setvar "CMDECHO" 0) (command "._UNDO" "G") (if (setq ss (ssget '((0 . "TEXT,POINT")))) (progn (initget "F N") (setq ans (getkword "\nInsert Block From <F>ile or <N>ame: ")) (cond ((= ans "F") (file)) ((= ans "N") (name)) ) (newblock) ) (princ "\nError - Nothing Seleted") ) (setvar "OSMODE" osm) (setvar "CLAYER" old) (command "._UNDO" "E") (princ) ) ;;;SubF Function for Place New Blocks (defun NewBlock () (setq l (sslength ss)) (setq c 0) (repeat l (setq ssnme (ssname ss c)) (setq ent (entget ssnme)) (setq OBJ (cdr (assoc 0 ent))) (cond ((= obj "POINT") (setq Chk10 (cdr (assoc 10 Ent))) (command "INSERT" user Chk10 "" "" "") ) ((= obj "TEXT") (setq c10 (cdr (assoc 10 ent))) (setq c11 (cdr (assoc 11 ent))) (setq er1 (list 0.0 0.0 0.0)) (setq er2 (list 0.0 0.0 (caddr c10))) (if (or (equal c11 er1) (equal c11 er2)) (command "Insert" user c10 "" "" "") (command "Insert" user c11 "" "" "") ) ) ) (setq c (1+ c)) ) ) ;;Sub Function For Browse from file (defun File() (setq user(getfiled "Select New Block" "" "dwg" 2)) (if (= user Nil) (exit) ) ) ;;Sub Function (defun name() (setq user(getstring "\nEnter Block Name To Insert:")) (setq block(Tblsearch "BLOCK" user)) (if (= Block Nil) (progn (princ"\nNo Block Found in this Name..") (exit) ) ) ) ;;;;;END INSERT BLOCK FUNCTION ................................................. Quote
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.