Import point + text on different layer lisp

Import point + text on different layer lisp

Anonymous
Not applicable
1,484 Views
2 Replies
Message 1 of 3

Import point + text on different layer lisp

Anonymous
Not applicable

Hy,

 

im a rookie with lisp, so i need an help (a big one) to complete a lisp.

I have an external txt file with a lot lines. The columns are in this way:

 

 

1st COLUMN: PROGRESSIVE NUMBER
2nd COLUMN:	x COORDINATE
3rd COLUMN: 	y COORDINATE	
4th COLUMN: 	z COORDINATE		
5th COLUMN:  DESCRIPTION

 

 

and i need to create in autocad a point with the coordinate and three texts at his side: the point and the texts must be on different layers and i need a separate block for every point with its texts (a block for every line of the external file).

 

my idea was something like this:

 

 

1-	IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV BLOCK” (INDEX COLOR YELLOW: 2)
2-	IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV POINT” (INDEX COLOR YELLOW: 2)
3-	IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV TEXT NUMBER” (INDEX COLOR YELLOW: 2)
4-	IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV TEXT Z” (INDEX COLOR GREEN: 3)
5-	IF THE LAYER DOESN’T EXIST: CREATE LAYER “LEV TEXT ANNOTATION” (INDEX COLOR RED: 1)

6-	COMMAND “PDMODE” “32”
7-	SETQ “HEIGHTofTEXT”
8-	HIDE OBJECTS: ALL

9-	CURRENT LAYER: LAYER “LEV POINT” 
10-	CREATE POINT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN 3rd COLUMN, 4th COLUMN)
11-	CURRENT LAYER: LAYER  “LEV TEXT NUMBER”
12-	CREATE MTEXT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN+“HEIGHTofTEXT”*1.5,  3rd COLUMN+“HEIGHTofTEXT”*1.5, 4th COLUMN)(TEXT HEIGHT “HEIGHTofTEXT”)(TEXT: NUMBER IN THE 1st COLUMN)
13-	CURRENT LAYER: LAYER  “LEV TEXT Z”
14-	CREATE MTEXT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN+“HEIGHTofTEXT”*1.5,  3rd COLUMN, 4th COLUMN)(TEXT HEIGHT “HEIGHTofTEXT”)(TEXT: NUMBER IN THE 4th COLUMN)
15-	CURRENT LAYER: LAYER  “LEV TEXT ANNOTATION”
16-	CREATE MTEXT (IMPORT FROM EXTERNAL FILE THE COORDINATE (1st LINE: 2nd COLUMN+“HEIGHTofTEXT”*1.5,  3rd COLUMN-“HEIGHTofTEXT”*1.5, 4th COLUMN)(TEXT HEIGHT “HEIGHTofTEXT”)(TEXT: TEXT IN THE 5th COLUMN)

17-	CURRENT LAYER: LAYER “LEV BLOCK” 
18-	SELECT: ALL
19-	CREATE BLOCK
20-	HIDE OBJECTS: ALL

21-	REPEAT FROM 9 TO 20 FOR ALL THE LINES IN THE EXTERNAL FILE

22-	UNHIDE OBJECTS

 

 

I started to write the lisp and i arrive at the point 9 in this way:

 

 

(defun C:LEV ()
  
  (command "_.layer" "_MAKE" "LEV BLOCK" "COLOR" "2" ""
   "_MAKE" "LEV POINT" "COLOR" "2" ""
   "_MAKE" "LEV TEXT NUMBER" "COLOR" "2" ""
   "_MAKE" "LEV TEXT Z" "COLOR" "3" ""
   "_MAKE" "LEV TEXT ANNOTATION" "COLOR" "1" "" "")
	   
   (COMMAND "PDMODE" "32" "")
   (COMMAND "HIDEOBJECTS" "ALL" "")
   (COMMAND "_.CLAYER" "LEV POINT" "")

(PRINC)  
)

 

 

From here i dont know how to import the coordinate to create the points, the coordinate to create the text (my idea is to use the coordinate of the point and move a little bit the text on the right using the height of the text X a number)

 

Somebody can help me? I will appreciate a lot.

0 Likes
1,485 Views
2 Replies
Replies (2)
Message 2 of 3

john.uhden
Mentor
Mentor

What you are describing looks almost exactly like the old DCA / Softdesk "Point" block.  Softdesk was acquired by Autodesk and became Land Desktop.

Have you considered using attributes instead of text?

 

The Softdesk Point block consists of an AutoCAD point on Layer 0 at its insertion point plus three (3) attributes for:

Point# on layer PNTS

Elev on layer ELEV

Description on layer DESC

 

If I don't already have it, it wouldn't be very hard to write a Lisp routine to read your file(s) and import all the points.

Normally, such point files look like the following format for each line:

P,N,E,Z,D  (Northings and Eastings)

or

P,X,Y,Z,D

Most land surveyors will provide ASCII point files in this format.

 

When you get a little more sophisticated, you insert the blocks on layer names relative to the description so you can freee and thaw them based on the type of plan you are preparing, for example

EP-GAS

EP-CURB

EP-DRAIN

EP-SAN

EP-STEAM

EP-FENCE

EP-WALK

EP-PVMT

 

where EP represents "Existing Point"

and you control the size and appearance by a combination of the insertion scale and PDSIZE (and PDMODE).

When you freeze the layer in which a block is inserted, the attributes are frozen with it.

 

OR, why don't you start using Civil 3D.  It has all the importation and appearance methods.

John F. Uhden

0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant

I also thought [without knowing anything about Civil-oriented overlay software] that a Block with Attributes would be better.  Parts of it can be on different Layers if you like.  It can be Inserted with only one insertion point to calculate [the spatial relationship between the Point and the Attributes would be built into the Block], and the Attribute values can be fed into the end of the Insert command by reading from the external file.

 

What is the actual format of a line from that file?  Are the pieces separated by spaces, or tabs, or commas, or...?

 

These two lines:

 

   (COMMAND "PDMODE" "32" "")
...
   (COMMAND "_.CLAYER" "LEV POINT" "")

 

shoudn't have the extra Enter [""] at their ends.  They just setting System Variables -- giving them a value ends the command, and there's no need to further "complete" it in the way that [for example] you need to complete object selection [the one in between those] or get out of a command that is still offering options [such as Layer].  In fact, they can be more direct, since using a System Variable name as though it's a command name is the "long way around."  They can be just:

   (setvar 'PDMODE 32)
...
   (setvar 'CLAYER "LEV POINT")

 

You can even omit that last one entirely if you make this sub-line in the Layer command:

 

"_MAKE" "LEV POINT" "COLOR" "2" "" ""

 

the last one in it [with two Enters at the end of that line, rather than the other line], because it will leave that Layer current, so there will be no need to later set it current.

Kent Cooper, AIA
0 Likes