Jump to content

Convert block attributes to point


Organic

Recommended Posts

I have been provided with a few DWG survey files from a surveyor who I believe has used Carlson survey software addon for AutoCad to complete the survey. The survey points all come in on a layer called 'PTS' and each point is comprised of an attributed block that houses attributes for the description, height and point number for the point. 

 

I need to put the points on their own layer and retain the heights. E.g. NS points on a layer called NS and each point has its height. 

 

If I edit the block to add a point at the basepoint then when I explode the block the point will take on the height of the block although all points are then on a layer called PTS. Does anyone have any lisp tools or know of other ways of doing this in AutoCad where the would would be put on a layer representing their code (e.g. layers NS, TB etc)?

Sample survey points.dwg

Edited by Organic
Edit: sample file of blocks attached
Link to comment
Share on other sites

Could you re-post the drawing in AutoCAD 2010 format. I have several routines that do something similar to what you want, but none specific to Carlsson Survey format. This used to be a major problem, as everyone seemed to have their own internal "point" format.

 

Link to comment
Share on other sites

Very straight forward just need some time. Organic you should be able to do it.

 

Just ssegt the "SRVPNO1" blocks

 

Just get the insertion point of the block this give Z value

Get layer name from the attribute do a (tblsearch "layers" desc) make if not exist

Then make a point

 

 

Link to comment
Share on other sites

Ok, I have two blocks "SRVPNO1" and "SPT10". The first is the block of three attribute, the second a block of a cross (two lines),  I assume to be the representation of a point.

 

Which attributes do you want to retain, and in which layer(s), and what do you want to do with the "point" block?

 

How do you want to represent the point, a point entity?

Link to comment
Share on other sites

dlanorh dont worry about 2 blocks as insert point is at correct xyz point.

 

; Create point at xyz from survey code block
; By Alan H info@alanh.com.au

(defun lay-miss (misslay / )
(if (= (tblsearch "layer" misslay) "T")
(princ (strcat "\n" misslay))
(command "-layer" "m" misslay "")
)
(setvar 'clayer misslay)
)



(defun survpoint ( / ss x att obj ins newlay)
(setq ss (ssget "X" (list (cons 0 "Insert")(cons 2 "SRVPNO1"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq ins (vlax-get Obj 'insertionPoint))
(foreach att (vlax-invoke obj 'getattributes)
        (if (= (vla-get-tagstring att) "DESC2" )
		(progn
        (setq newlay (vla-get-textstring att))
		(princ (strcat "\n" newlay))
		(lay-miss newlay)
		)
		)
        (command "point" ins)
)
)
)
(survpoint)

 

Edited by BIGAL
Link to comment
Share on other sites

1 hour ago, BIGAL said:

dlanorh dont worry about 2 blocks as insert point is at correct xyz point.

 


; Create point at xyz from survey code block
; By Alan H info@alanh.com.au

(defun lay-miss (misslay / )
(if (= (tblsearch "layer" misslay) "T")
(princ (strcat "\n" misslay))
(command "-layer" "m" misslay "")
)
(setvar 'clayer misslay)
)



(defun survpoint ( / ss x att obj ins newlay)
(setq ss (ssget "X" (list (cons 0 "Insert")(cons 2 "SRVPNO1"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq ins (vlax-get Obj 'insertionPoint))
(foreach att (vlax-invoke obj 'getattributes)
        (if (= (vla-get-tagstring att) "DESC2" )
		(progn
        (setq newlay (vla-get-textstring att))
		(princ (strcat "\n" newlay))
		(lay-miss newlay)
		)
		)
        (command "point" ins)
)
)
)
(survpoint)

 

 

I know, but do we need to delete them etc..? 

Link to comment
Share on other sites

Thanks Bigal that achieves what I need. 😁 I have still not managed to get my head around more than the basics of lisp :|

 

Dlanorh, I don't quite understand what Bigal's code does although it does seem to insert multiple points (at the same location); I'm, not sure if that is to do with the block though or if it is inserting one point per attribute? Overkill solves the duplicated points though and leaves just a single point. 😐

Edited by Organic
Link to comment
Share on other sites

2 hours ago, Organic said:

Thanks Bigal that achieves what I need. 😁 I have still not managed to get my head around more than the basics of lisp :|

 

Dlanorh, I don't quite understand what Bigal's code does although it does seem to insert multiple points (at the same location); I'm, not sure if that is to do with the block though or if it is inserting one point per attribute? Overkill solves the duplicated points though and leaves just a single point. 😐

 

See attached commented version of BIGAL's routine

 

My inquiry was about what you want to do with the "SRVPNO1" and "SPT10" blocks. Did you want them deleting; and more specifically, did you want any of the other attibutes values, i.e. you could convert them into text entities in the same layer they are in the block. The level attribute might not be required, the description is used to put the point on the required layer but you may need the point number?

 

This could all be combined into a short single lisp routine

BIGAL1.lsp

Link to comment
Share on other sites

Thanks Tharwat and dlanorh I corrected the If for the layer and moved the make point a couple of lines up so now will only be once a oversight by me, just looked at the visual result when testing. 

 

Code updated above.

 

Note in the dwg there is a "Point" on layer PNTS that already exists so should that be deleted  or at least frozen ?

 

 

BIGAL 1.lsp

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...