Trying to write a custom linetype and getting 'Error undefined linetype'
Having had limited luck trying to find a 'true' sinusoidal linetype (closest I managed to find was a series of semicircles) I thought I'd try my hand writing my own. I've gone through the process of writing an SHP file with one sinusoidal curve, compiling the shape using BCADTools and loading the compiled shape to check that it looks as expected. That all works fine. What's tripping me up is the LIN file. It doesn't seem to matter where I put the SHX file (it's been tried in each of the folders on my support path) I still get an error 'Undefined linetype'. Altering the LIN file to have a simple linetype definition in place of the reference to the SHX file results in a working LIN file but putting the SHX reference in just results in the above error.
I did wonder if my SHX file is too big? Is there a limit on the detail in the SHX file or the size of the shape? Now I'm a bit more familiar with LIN files I realise that I don't need my SHX file to have an entire 'sinusoidal wave' - it can just have the top half and a mirror of the top half. Also, there's part of most complex linetype definitions that I don't understand - in the Batting definition below there appears to be:
- a line (0.00254)
- a space (-2.54)
- the batting shape
- another space (-5.08)
- the batting shape again, this time rotated through 180 degrees
- another space (-2.54)
*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
A,.00254,-2.54,[BAT,ltypeshp.shx,x=-2.54,s=2.54],-5.08,[BAT,ltypeshp.shx,r=180,x=2.54,s=2.54],-2.54
How come there are no spaces when a batting line is drawn?
For reference, here's the LIN file I've written:
*SINELINE,ABCDE
A,1,[SINE,sineshp.shx]
and the content of the SHP file (sorry about the size & apologies but I can't see a way of attaching the compiled SHX file):
*001,309,SINE
;;; First quadrant
9,(114,93),(63,52),(51,41),(61,49),(54,43),(60,47),(54,42),(60,46),(54,40),(60,44),(55,39),(59,41),(55,37),(0,0),
9,(59,39),(55,34),(59,36),(55,32),(60,33),(55,29),(59,29),(55,26),(59,26),(55,22),(59,22),(56,19),(59,18),(0,0),
9,(55,15),(59,14),(55,11),(60,10),(55,7),(58,5),(56,3),(57,0),(0,0),
;;; Second quadrant
9,(57,0),(56,-3),(58,-5),(55,-7),(60,-10),(55,-11),(59,-14),(55,-15),(0,0),
9,(59,-18),(56,-19),(59,-22),(55,-22),(59,-26),(55,-26),(59,-29),(55,-29),(60,-33),(55,-32),(59,-36),(55,-34),(59,-39),(0,0),
9,(55,-37),(59,-41),(55,-39),(60,-44),(54,-40),(60,-46),(54,-42),(60,-47),(54,-43),(61,-49),(51,-41),(63,-52),(114,-93),(0,0),
;;; Third quadrant
9,(114,-93),(63,-52),(51,-41),(61,-49),(54,-43),(60,-47),(54,-42),(60,-46),(54,-40),(60,-44),(55,-39),(59,-41),(55,-37),(0,0),
9,(59,-39),(55,-34),(59,-36),(55,-32),(60,-33),(55,-29),(59,-29),(55,-26),(59,-26),(55,-22),(59,-22),(56,-19),(59,-18),(0,0),
9,(55,-15),(59,-14),(55,-11),(60,-10),(55,-7),(58,-5),(56,-3),(57,0),(0,0),
;;; Fourth quadrant
9,(57,0),(56,3),(58,5),(55,7),(60,10),(55,11),(59,14),(55,15),(0,0),
9,(59,18),(56,19),(59,22),(55,22),(59,26),(55,26),(59,29),(55,29),(60,33),(55,32),(59,36),(55,34),(59,39),(0,0),
9,(55,37),(59,41),(55,39),(60,44),(54,40),(60,46),(54,42),(60,47),(54,43),(61,49),(51,41),(63,52),(114,93),(0,0),
0
;;; 1 2 3 4 5 6 7 8 9 0 1 2 8
Comments
-
Sorry, meant to say thanks for any help at the end
0 -
> How come there are no spaces when a batting line is drawn?
If there were not spaces in the linetype definition a continuous line would intersect the BAT shapes.> I did wonder if my SHX file is too big?
No. But using such a detailed shape can be a bad idea. If you use this linetype a lot you can expect much bigger plot and pdf files. A 'low res' shape will perform better and, depending on scale etc., may look just as good. I would try using 3 arc segments for a half 'SINE'. Or even a line-arc-line solution. Using arcs will reduce pdf sizes but on the other hand can increase plot file sizes. I have been testing this recently. In my test a dwg with 100 batting lines each containing 27 pattern repetitions produced a plot file (HPGL2) of 5.1MB. Using a BAT shape with a real arc (instead of BC's facetted shape) increased the size of the plotfile to 5.9MB, but reduced the size of the pdf file from 800kB to 417kB.The mistake in your linetype defintion: you forgot the scale for the shape. Try this:
*SINELINE,ABCDE
A,.00000001,[SINE,sineshp.shx,s=.001],-8You will notice that both this linetype and the batting linetype start with a small dash. It is there to 'take up the slack'. If you zoom way in on a batting line you will see the small dash after every 2 BAT shapes.
0 -
BTW:
I'm not sure why the batting linetype is defined the way it is (some other cad program is perhaps using this definition...), but this version produces the exact same effect in the dwg:
*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
A,.00254,[BAT,ltypeshp.shx,s=2.54],-10.16,[BAT,ltypeshp.shx,r=180,s=2.54]0 -
OOPS, scrap that last post of mine. There is definitely a difference when the linetype is used with arc segments, circles and polylines with linetype generation enabled.
0 -
Hi Roy,
Thanks for the reply - I'm kicking myself as the missing scale issue looks so obvious now it's been pointed out, sure I'd still be scratching my head over it tomorrow if without your help though. Will have a go amending the file tomorrow when I'm back in the office.
I'll perhaps simplify my shape definition - thanks for the suggestion. I'd mocked it up in modelspace in BricsCAD to get the dimensions to put in the shape file so it shouldn't be too onerous to see how approximating the shape using arcs will look. We tend to save all our drawings to PDFs as easy means of distribution (probably used more frequently these days than sending prints) so something that should reduce the size of the PDFs would be welcome.
Thanks again!
Regards,
Chris
0 -
Since there are many ways to create a pdf I should mention that I have used Bricscad's export to pdf option. Using a pdf-printer the differences are much smaller. This is because arcs automatically become facetted in the printing process.
All tests with a drawing with 100 lines each displaying the pattern 27 times:
BRICSCAD EXPORT TO PDF:
LtypeTest_Bat_Arc.pdf => 417kB
LtypeTest_Bat_Facetted.pdf => 800kB
LtypeTest_Sine.pdf => 3.3MB!
PDF PRINTER (PDF REDIRECT V2)
LtypeTest_Bat_Arc.pdf => 225kB
LtypeTest_Bat_Facetted.pdf => 260kB
LtypeTest_Sine.pdf => 329kB0 -
On the subject of exports, I had been experimenting to try and export to PDF keeping text entities intact.
The aim was to convert Pspace layouts to Model space, by going from DWG to PDF back to DWG using a converter program. Why is another story.
The Bricscad export retained text information, but I don't believe any PDF print programs I tried did.
Retaining text information might make the PDF files bigger, as might other information which makes the file less of a snapshot. Just a guess.
0