Revit API

Reply
Active Contributor
mfleming.stantec
Posts: 32
Registered: ‎10-06-2009
Message 1 of 15 (1,932 Views)
Accepted Solution

Create Line Pattern Type?

1932 Views, 14 Replies
10-18-2012 10:01 PM

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

 

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;
}

Distinguished Contributor
Revitalizer
Posts: 110
Registered: ‎09-07-2012
Message 2 of 15 (1,920 Views)

Re: Create Line Pattern Type?

10-22-2012 12:23 AM in reply to: mfleming.stantec

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

Active Contributor
mfleming.stantec
Posts: 32
Registered: ‎10-06-2009
Message 3 of 15 (1,907 Views)

Re: Create Line Pattern Type?

10-24-2012 06:23 PM in reply to: Revitalizer

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.

ADN Support Specialist
jeremytammik
Posts: 627
Registered: ‎08-20-2007
Message 4 of 15 (1,891 Views)

Re: Create Line Pattern Type?

10-31-2012 04:07 AM in reply to: mfleming.stantec

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

Distinguished Contributor
Revitalizer
Posts: 110
Registered: ‎09-07-2012
Message 5 of 15 (1,889 Views)

Re: Create Line Pattern Type?

10-31-2012 04:16 AM in reply to: mfleming.stantec

Hi Jeremy,

 

so, it is possible to

-create new GraphicsStyles plus

-assigning user-defined LinePatterns to them ?

 

Bye,

Revitalizer

ADN Support Specialist
jeremytammik
Posts: 627
Registered: ‎08-20-2007
Message 6 of 15 (1,884 Views)

Re: Create Line Pattern Type?

10-31-2012 04:30 AM in reply to: Revitalizer

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

Distinguished Contributor
Revitalizer
Posts: 110
Registered: ‎09-07-2012
Message 7 of 15 (1,881 Views)

Re: Create Line Pattern Type?

10-31-2012 05:25 AM in reply to: jeremytammik

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

ADN Support Specialist
Joe.Ye
Posts: 333
Registered: ‎03-05-2010
Message 8 of 15 (1,874 Views)

Re: Create Line Pattern Type?

11-01-2012 02:16 AM in reply to: Revitalizer

 

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
Distinguished Contributor
Revitalizer
Posts: 110
Registered: ‎09-07-2012
Message 9 of 15 (1,855 Views)

Re: Create Line Pattern Type?

11-05-2012 12:00 AM in reply to: mfleming.stantec

Hi joe.ye,

 

thank you for your code snippet !

 

Cheers,

Revitalizer

Active Contributor
mfleming.stantec
Posts: 32
Registered: ‎10-06-2009
Message 10 of 15 (1,842 Views)

Re: Create Line Pattern Type?

11-07-2012 10:44 AM in reply to: mfleming.stantec

Thanks Joe

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!