Create Line Pattern Type?

Create Line Pattern Type?

mfleming.stantec
Enthusiast Enthusiast
9,018 Views
14 Replies
Message 1 of 15

Create Line Pattern Type?

mfleming.stantec
Enthusiast
Enthusiast

I'm trying to create a couple custom line patterns with Revit API in 2013.

 

Using the 2013 SDK sample CreateFillPattern I can retrive all line styles as well as assign them to grids.

 

I'm looking for a way to be able to CREATE new types.

 

Is this possible in 2013 API?

 

Matt

0 Likes
Accepted solutions (1)
9,019 Views
14 Replies
Replies (14)
Message 2 of 15

Revitalizer
Advisor
Advisor

Dear mfleming.stantec,

 

as far as I know, there is no way to create new line patterns.

You can create new FillPatterns, but not LinePatterns.

 

I myself tried to create a new line pattern representing railroads or gas pipilines, for example, menaning I needed a line pattern containing text.

I need to work around the problem, ending in using a new line-based Family with parameters to set the text properties.

Resulting in something like "---GAS---GAS---GAS---" or "=|=|=|=|=|=|=|=|=|=|=|=|=", for example.

For curves, the distribution of FamilyInstances needs to be approximated to adjust the straigt elements to curved ones.

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 3 of 15

mfleming.stantec
Enthusiast
Enthusiast

All I'm looking to do is create new line pattern, Set value to either Dash, Space,Dot ect and give the value.

It's not a "custom" line pattern.

 

There has to be a way to do this.

0 Likes
Message 4 of 15

jeremytammik
Autodesk
Autodesk

Have you looked at the LinePattern class?

There is a LinePatternElement.Create method...



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 15

Revitalizer
Advisor
Advisor

Hi Jeremy,

 

so, it is possible to

-create new GraphicsStyles plus

-assigning user-defined LinePatterns to them ?

 

Bye,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 6 of 15

jeremytammik
Autodesk
Autodesk

Hi Revitalizer,

 

Sorry, I don't know off-hand. I would need a sample to explore.

 

Cheers, Jeremy.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 15

Revitalizer
Advisor
Advisor

Hi Jeremy,

 

I've created FillPatterns in many, many variations so far.

But I did not create LinePatterns yet.

 

I think it would only make sense to create such Elements if we also could create new GraphicsStyles for them.

If we only can assign new LinePattern to existing GgraphicsStyles, we just would *override* existing settings...

 

Perhaps you could blog about LinePatterns and how to create them ?

 

 

Cheers,

Rudolf




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 8 of 15

Joe.Ye
Alumni
Alumni
Accepted solution

 

I happen to have some lines to create a line pattern.

 

private LinePatternElement CreateLinePatternElement(string patternName)
{
//Create list of segments which define the line pattern
List<LinePatternSegment> lstSegments = new List<LinePatternSegment>();
lstSegments.Add(new LinePatternSegment(LinePatternSegmentType.Dot, 0.0));
lstSegments.Add(new LinePatternSegment(LinePatternSegmentType.Space, 0.02));
lstSegments.Add(new LinePatternSegment(LinePatternSegmentType.Dash, 0.03));
lstSegments.Add(new LinePatternSegment(LinePatternSegmentType.Space, 0.02));

LinePattern linePattern = new LinePattern(patternName);
linePattern.SetSegments(lstSegments);

Transaction trans = new Transaction(doc);
trans.Start("Create a linepattern element");
LinePatternElement linePatternElement = LinePatternElement.Create(doc, linePattern);
trans.Commit();
return linePatternElement;
}



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 9 of 15

Revitalizer
Advisor
Advisor

Hi joe.ye,

 

thank you for your code snippet !

 

Cheers,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 10 of 15

mfleming.stantec
Enthusiast
Enthusiast

Thanks Joe

0 Likes
Message 11 of 15

RocksterB
Advocate
Advocate

Joe, how do I load the line pattern code you've provided into Revit?

0 Likes
Message 12 of 15

Anonymous
Not applicable

Hi,

 

Am i correct in saying you can not set line pattern to a category?

 

Regards


Chris

0 Likes
Message 13 of 15

jeremytammik
Autodesk
Autodesk

Dear Chris,

 

If you can do it through the user interface, it is probably possible programmatically as well, and vice versa. Is it possible in the UI?

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 14 of 15

chris.j.mckeown
Contributor
Contributor

Hi Jeremy,

 

I found the below post on the Autodesk site just after I posted this question...

http://forums.autodesk.com/t5/Autodesk-Revit-API/Line-Patterns/m-p/3110368/highlight/true#M2163

 

Yes it is possible via the UI but according to Saikat it is not possible via API yet.

 

I haven't checked 2014 yet. I notice in 2011 they had the method to set it but must have caused an error, so they (the factory) removed it in 2012/3 never to be seen again?

 

Regards

 

Chris

0 Likes
Message 15 of 15

Dale.Bartlett
Collaborator
Collaborator

Hi Joe, Do you have similar code to delete line patterns? Dale




______________
Yes, I'm Satoshi.
0 Likes