Create Line Type entering the two lines instead of a .lin name

Create Line Type entering the two lines instead of a .lin name

GeryKnee
Advocate Advocate
2,393 Views
20 Replies
Message 1 of 21

Create Line Type entering the two lines instead of a .lin name

GeryKnee
Advocate
Advocate

Hello to everyone.

User defined Line Types are based on a two lines string

Example

*MAP,--- Map ---
A,1.0,-0.5,["Map",mcstyle,S=1,R=0,X=0,Y=-0.5],-3.0

The text, i see, is inserting to autocad system by using a .lin txt file.

This causes time delay because of restoring from disk this simple string.

Is there a way to insert the string to autocad app not using the fi

 

 

0 Likes
Accepted solutions (1)
2,394 Views
20 Replies
Replies (20)
Message 2 of 21

Kent1Cooper
Consultant
Consultant

None that I can think of.  It won't be any simpler, but you could do it with involving another kind of file in a couple of ways:  1)  have a little drawing that has that Linetype [even with nothing drawn in it], INSERT that drawing into the current one, and it will bring the Linetype with it.  Or  2)  get into another drawing that has something drawn in that Linetype, and Copy/Paste that into the target drawing.  But in either case, that other source drawing, or another that it got it from in the same way, is going to need to have gotten the linetype from a .LIN file.

Kent Cooper, AIA
Message 3 of 21

GeryKnee
Advocate
Advocate

OK Kent,

Searching WEB about it, I see that it's not supported.

Thank you,

Gery.

 

 

0 Likes
Message 4 of 21

Moshe-A
Mentor
Mentor

@GeryKnee  hi,

 

causes time delay?

i do not remember that for very long time even in old AutoCAD versions under old OS platforms.

if you experiencing this on R2006, then there must be other reason - maybe slow system\disk.

 

MAP linetype uses mcstyle text style and if this text style is not exist when you load the .lin file you get an error that there is a bad definition of MAP at line xxxx of file cccccc.lin  and the linetype is ignored.

is this the time delay you are talking?!

 

Moshe

 

0 Likes
Message 5 of 21

GeryKnee
Advocate
Advocate

Hello Moshe-A,

I don't know if newer versions or software or new hardware sould be faster.

My system disk is SSD.

And the system is quite fast.

But, you know, if you need line types of isometric curves with the heights of earth , you need 9000 different line types wich souldn't be predeclared.

I do it , with a pascal code, creating the two text lines needed for creation of the line type , storing it in a temp .lin file and giving it to autocad app (AcadApp.ActiveDocumend.LineTypes.Load(Temp.lin file)).  Of course , sould exist an acad.Activedocumend.LineTypes.Add(LineTypeInfString). And that sould be 1.000.000 times faster than Load(Temp.lin file). And .lin file has just this simple string information.

Thank you Moshe,

Regards,

Gery.

 

0 Likes
Message 6 of 21

Moshe-A
Mentor
Mentor

@GeryKnee ,

 


But, you know, if you need line types of isometric curves with the heights of earth , you need 9000 different line types wich souldn't be predeclared.

 

what is heights of earth?

if you are using a lot of complex linetypes (in one drawing) than i assume the regeneration time is rising - is that what you mean as 'time delay'?

 

I do it , with a pascal code, creating the two text lines needed for creation of the line type , storing it in a temp .lin file and giving it to autocad app (AcadApp.ActiveDocumend.LineTypes.Load(Temp.lin file)).  Of course , sould exist an acad.Activedocumend.LineTypes.Add(LineTypeInfString). And that sould be 1.000.000 times faster than Load(Temp.lin file). And .lin file has just this simple string information.

 

or the time taking you to create linetypes in pascal?

 

 


then i still don't see where is the time delay? if i do, maybe will find another way to speed it up?!

 

0 Likes
Message 7 of 21

Sea-Haven
Mentor
Mentor

Can you explain more why you would have so many linetypes 9000 ? You can have a LTSCALE this changes the linetype display eg ltscale 2 will draw dashed twice the size. I use a equal dashed line type 1 space 1 so when draw a new road drain set ltscale to 2.4 so can quickly count pipes if needed.

 

You could add a line type to a custom.LIN file and load it into current dwg if you have to. Open "A" append. Lisp is ok to do.

0 Likes
Message 8 of 21

GeryKnee
Advocate
Advocate

OK Sea.heaven,

All around the world, in survey plans, line types are used to draw the isometric curves.

------ 0 ------------- 0 ------------- 0 -------------

------ 1 ------------- 1 ------------- 1 -------------

......

------ 5642 ------------- 5642 ------------- 5642 -------------

------ 5643 ------------- 5643 ------------- 5643 -------------

......

After creation of EACH ONE , LtScale is surely necessary to make lines of that type them vieable in survey plan (1:100 or 1:200 or 1:1000 or 1:2500 tc)

But indeed yoy need aboyr 8500 lines to draw isometric curves on earth and about 10500 isobath ones.

Of course, there's not a good method to create all those line types puting them on .lin files.

I did it creating each one using a pascal code.

 

I believe that in future , autocad will support this simple thing :

  The two lines needed for creation will be able to insert not from a text file (.lin) ,

     but getting the information from two strings conteents.

  for example.

Something like :

(defun c:CreateLineType ()

 (setq Str1 (getString "\nSpecify Line1 string: "))

 (setq Str2 (getString "\nSpecify Line2 string: "))

......................

)

That's enough. All parameters needed for creation exist in those two lines.

 

Of cousre the brilliant thing is that autocad can get those simple informations to (very) fast draw complicated objects. 

But what i referenced here is a good idea for code updates.

Regards,

Gery.

 

0 Likes
Message 9 of 21

Sea-Haven
Mentor
Mentor

Now I understand. The obvious answer is contours and label them so a line with elevation 6534 will auto label, if we could put a field in a linetype can use elevation, not sure about that.

 

If your happy can do a block with one attribute that reads the line elevation it has a wipe out. So would look like

------- 1234 --------- 1234 ---------- so 1 block 30000 values no problems.

It may be easier to go back a step how are you making the lines in the first place to know the value. Then auto block. There is plenty of Chainage.lsp out there it writes the chainage of a pline but no probs make a block with a value instead it will rotate to match pline. 

 

There is a few of us here that may have something if your happy to set a lines elevation ie Z. 

 

Please let us know if happy with this answer. Post a sample dwg so we can look at spacing text size etc.

 

Almost forgot have a read about LTSCALE and PSLTSCALE and annovative text.

 

 

 

 

 

 

 

Message 10 of 21

CADaSchtroumpf
Advisor
Advisor

@Sea-Haven  a écrit :

The obvious answer is contours and label them so a line with elevation 6534 will auto label

 


I absolutely agree with this suggestion.

If GeryKnee can have elevations for its polylines then this is a solution. For example with this:

(vl-load-com)
(defun c:Label_Side_Elevation ( / js htx AcDoc Space lg_repeat n obj ename pr pt deriv rtx nw_obj)
  (princ "\nSelect polylines: ")
  (setq js
    (ssget
      (list
        '(0 . "LWPOLYLINE")
        (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
        (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
      )
    )
  )
  (cond
    (js
      (initget 6)
      (setq htx (getdist (getvar "VIEWCTR") (strcat "\nGive text size <" (rtos (getvar "TEXTSIZE")) ">: ")))
      (if htx (setvar "TEXTSIZE" htx))
      (setq
        AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
        Space
        (if (= 1 (getvar "CVPORT"))
          (vla-get-PaperSpace AcDoc)
          (vla-get-ModelSpace AcDoc)
        )
      )
      (cond
        ((null (tblsearch "LAYER" "Label Elevation"))
          (vlax-put (vla-add (vla-get-layers AcDoc) "Label Elevation") 'color 96)
        )
      )
      (initget 7)
      (setq lg_repeat (getdist (getvar "VIEWCTR") "\nLength of label repeat ?: "))
      (repeat (setq n (sslength js))
        (setq
          obj (ssname js (setq n (1- n)))
          ename (vlax-ename->vla-object obj)
          pr (vlax-curve-getStartParam ename)
        )
        (while (and (vlax-curve-getParamAtDist ename lg_repeat) (< (setq pr (+ (vlax-curve-getParamAtDist ename lg_repeat) pr)) (vlax-curve-getEndParam ename)))
          (setq
            pt (vlax-curve-GetpointAtParam ename pr)
            deriv (vlax-curve-getFirstDeriv ename pr)
            rtx (- (atan (cadr deriv) (car deriv)) (angle '(0 0 0) (getvar "UCSXDIR")))
          )
          (if (or (> rtx (* pi 0.5)) (< rtx (- (* pi 0.5)))) (setq rtx (+ rtx pi)))
          (setq nw_obj
            (vla-addMtext Space
              (vlax-3d-point pt)
              0.0
              (strcat
                "{\\fArial|b0|i0|c0|p34;"
                "%<\\AcObjProp Object(%<\\_ObjId "
                (itoa (vla-get-ObjectID (vlax-ename->vla-object obj)))
                ">%).Elevation \\f \"%lu2%pr0\">%"
              )
            )
          )
          (mapcar
            '(lambda (pr val)
              (vlax-put nw_obj pr val)
            )
            (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation 'BackgroundFill)
            (list 5 (getvar "TEXTSIZE") 5 pt "Standard" "Label Elevation" rtx -1)
          )
        )
      )
    )
  )
  (prin1)
)

 

Or if he use Autocad Map and have Object Data, he can be also use a lisp code to labelize ...

0 Likes
Message 11 of 21

hak_vz
Advisor
Advisor

@CADaSchtroumpfNice work.

 

This method generates elevation tags at distance along elevation curve. It generates good result when elevation curves (isohypses) are long and relatively straight. If you have complex terrain result is not so well since marking can be placed at weird position.

Better option is to avoid full automation and place elevation marks along a intersection with temporary line with some step value along z coordinates. This can be either at 1 meter, at every even z or odd z (very rare), or at z that is divisible with 5 or 10.

From my 20 years of practice, there are situations that contours are not elevated to its true z elevation, so in algorithm one can add a code that counts intersections and rises contours in regard to step from some starting value.

 

In attachment is my result using your code on one some real terrain data.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 12 of 21

GeryKnee
Advocate
Advocate

Hello Sea.Heaven.

Thank you very much for your help.

I've been allready solved the whole problem.

First,

Using delphi i made a code auto - constructing 99 .lin arcives containing (each one) 100 Line Type definitions.

For example 56.lin contains

*H_5600 ....

*H_5601 ....

....................

*H_5699 ....

Those 99 goups of 100 LT definitions support all earth heights

manually i inserted the 99 .lin LT groups to 99 .dwg .

I did it manually because -Linetype unfortunatelly has problems.

OK, i did it.

When i need a height LT (for example 1245) , if no H_1245 is member of Doc Linetypes , my pascal code inserts the 12.dwg in my document as exploded and purged block.

After insert, my document has 100+ line LT (H_1201,H_1202...H1255).

After using some of them ( 1245,1246...) , purgeAll will hold only the used ones and noone block added.

That's a good solution.

About polylines, the isometric and isobath lines are smooth lines and splineis the type of line representing the drwing. 

But the real solution is THE AUTOCAD SUPPORT ADDING LT USING STRING.

You are a very clever person and you undestand what i say.

And sure i believe that in the future will be an update.

And the same will occure about the badly designed -LineType.

AUTODESK made a so brilliant software, the top drawing software.

But after Autocad 14 wich was fully functional and an earhquake in CAD environment, the folowing updates were (it's my opinion) in a wrong direction. If Autocad 14 sould work ob 32 bit platforms, i sould work with it until i die.

Thank you very much sea.heaven.

Regards,

Gery.

 

I send you screenshots

01.jpg

02.jpg

03.jpg

04.jpg

0 Likes
Message 13 of 21

hak_vz
Advisor
Advisor

@GeryKnee

In my own opinion generating linetype for each contour elevation is bad idea. First thing that crosses my mind is that you (or users after you) will have  linetype selection drop-down menu polluted with hundreds entities.

 

There are many lisp codes available for placing contour elevations.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 14 of 21

GeryKnee
Advocate
Advocate

Hello Hack_vz,

Thank you very much for your help.

What you say about drop down menu is right.

But I never use it after 2000 when i started adapting autocad  acording to my mentality using OLE automation .

I use my dialog.

And is easy to do this work with this.

I give a first value to edit pox.

After that, one object has the line type.

When an object exists, buttons +1 +2 +5 +10 -1 -2 -5 -10 give me the ability to navigate the next Z and complete my work with iso lines.

After finished purgeAll erases all unused LT and the drop down menu is now OK.

Regards,

Gery.

0 Likes
Message 15 of 21

Kent1Cooper
Consultant
Consultant

@GeryKnee wrote:

......

------ 5642 ------------- 5642 ------------- 5642 -------------

------ 5643 ------------- 5643 ------------- 5643 -------------

......


You may be able to use LabelElevMask.lsp with its LEM command, available >here<.  It reads the Z coordinate of the path object [any kind with linearity] where you pick, and puts in Text with a wipeout [does not Break the path], middle-centered at the selection point over the path object, and aligned with it in the more plan-readable direction.  That has the benefit, in my mind, that you can label contour lines, etc., where you want to put labels, and not have them forced to every fixed distance along the paths, which you would have no control over with a linetype, and which I would usually find looks too cluttered.  Also, you can label a path object that's too short for a linetype to include the text element [assuming the linetype definition cycle is long enough that the text elements are not ridiculously close together].

Kent Cooper, AIA
0 Likes
Message 16 of 21

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
.... you can label contour lines, etc., where you want to put labels, and not have them forced to every fixed distance along the paths, which you would have no control over with a linetype....

An example:  If the white at the top is the continuous-linetype path of a contour line [not an unusual kind of shape], you might hope that a text-containing linetype would end up with the text elements "landing" something like the way they do in the red one.  But depending on the extent of the contour, at the mercy of things that could be far away, it could come out like any of the others, which can obscure the information.

Kent1Cooper_0-1617201705175.png

That's why I prefer to place labels where I want them, not at fixed spacings, clear of this kind of interference and clear of any other drawn objects, and with their locations remaining where they are even if I Trim or Extend or Stretch the remote end(s) of the contour somehow.

 

But, of course, as independent objects, labels such as I prefer don't adjust automatically if I alter the route of the contour, as the text elements in a linetype would -- I would need to re-label.  [But in the case of existing contours specifically, I don't think I ever alter them in that way -- it would apply only to proposed new contours, and possibly to non-contour situations, whatever they might be.]

Kent Cooper, AIA
0 Likes
Message 17 of 21

Sea-Haven
Mentor
Mentor

Very nice Kent, I knew some one would have something, re labelling it may be 3 options can help, manual, distance and drag. The drag is like CIV3D drag line over the contour lines and "intersectwith" defines the label point for multiple contours. Its really up to JeryKnee.

0 Likes
Message 18 of 21

Sea-Haven
Mentor
Mentor
Accepted solution

This is a linetype load

 

(defun loadLinetype (doc LineTypeName FileName)
  (if (and
        (not (existLinetype doc LineTypeName))
        (vl-catch-all-error-p
          (vl-catch-all-apply
            'vla-load
            (list
              (vla-get-Linetypes doc)
              LineTypeName
              FileName
            )
          )
        )
      )
    nil
    T
  )
)

(defun existLinetype (doc LineTypeName / item loaded)
  (vlax-for item (vla-get-linetypes doc)
    (if (= (strcase (vla-get-name item)) (strcase LineTypeName))
      (setq loaded T)
    )
  )
)

;load missing linetypes
;;; returns: T if loaded else nil
(loadLinetype doc "Fence" "custom.lin")
Message 19 of 21

GeryKnee
Advocate
Advocate

Yes, Sea.heaven,

This time it's the best lisp code.

And this is what i did usind pascal and OLE.

Now i'll change my code using it, because every routine you change with lisp code is faster and better in CAD automation.

Thank you very much,

Gery.

0 Likes
Message 20 of 21

GeryKnee
Advocate
Advocate

That's working perfectly

 


(defun existLinetype (doc LineTypeName / item loaded)
(vlax-for item (vla-get-linetypes doc)
(if (= (strcase (vla-get-name item)) (strcase LineTypeName))
(setq loaded T)
)
)
)
(defun loadLinetype (doc LineTypeName FileName)
(if (and
(not (existLinetype doc LineTypeName))
(vl-catch-all-error-p
(vl-catch-all-apply
'vla-load
(list
(vla-get-Linetypes doc)
LineTypeName
FileName
)
)
)
)
nil
T
)
)
(defun c:LLT(/ )
if(and
(setq LTName (getString "\nSpecify LT name: "))
(setq LinFileName (getString "\nSpecify .Lin File Name: "))
)
(loadLinetype (vla-get-ActiveDocument (vlax-get-acad-object)) LTName LinFileName)
(princ) )
)

 

0 Likes