cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

SET STYLE in PARAGRAPH

Anonymous
Not applicable
Has anyone gotten this to work?

When I try to use the "SET STYLE" function within the PARAGRAPH statement I get the message "Illegal command inside PARAGRAPH definition..."

Since I have done this precisely as indicated in the GDL reference, and the PEN and MATERIAL functions work, all I can think is W-T-F!?!?

Am I missing something here or is it just broken?
7 REPLIES 7
This working for me in 2D or 3D. The PARAGRAPH and TEXTBLOCK are defined in the master so both can use it.

! MASTER SCRIPT

DEFINE STYLE{2} 'sty1' 'Arial', txtsz, 0
DEFINE STYLE{2} 'sty2' 'Times', txtsz*0.8, 0
DEFINE STYLE{2} 'sty3' 'Times', txtsz*1.1, 0


PARAGRAPH "par1" 1, 0, 0, 0, 1.0, 1.0
	PEN 52
	SET STYLE 'sty1'
	MATERIAL 1
	"On one side, New Bedford rose in terraces of streets, their ice- covered trees all glittering in the clear, cold air. "
	PEN 42
	SET STYLE 'sty2'
	"Huge hills and mountains of casks on casks were piled upon her wharves, " 
	"and side by side the world-wandering whale ships lay silent and safely moored at last; "
	"while from others came a sound of carpenters and coopers, " 
	"with blended noises of fires and forges to melt the pitch, "
	PEN 32
	"all betokening that new cruises were on the start; "
	"that one most perilous and long voyage ended, only begins a second; "
	MATERIAL 2
	"and a second ended, only begins a third, and so on, for ever and for aye. " 
	SET STYLE 'sty3'
	"Such is the endlessness, yea, the intolerableness of all earthly effort."
ENDPARAGRAPH

TEXTBLOCK "block1" 100, 1, 0, 1.0, 1.0, 1, "par1"


! 2D SCRIPT

RICHTEXT2 0,0, "block1"


! 3D SCRIPT

RICHTEXT 0,0, 1', 0, "block1"
James Murray

Archicad 27 • Rill Architects • macOS • OnLand.info
Anonymous
Not applicable
What's up with my code then? When I substitute a string parameter for a text block, the style specified won't apply to it. A normal text string works OK.

Anssi
I did some experimenting and I don't think it's working as intended.

This is the style part of my master script.
DEFINE STYLE 'txtsty' txtFnt,txtsz,5,0
SET STYLE 'txtsty'

DEFINE STYLE{2} 'sty1' 'Arial', txtsz, 0
DEFINE STYLE{2} 'sty2' 'Times', txtsz*0.8, 0
DEFINE STYLE{2} 'sty3' 'Times', txtsz*1.1, 0
That first DEFINE STYLE is a standard bit of my object template, and it shouldn't be involved but it is.

Strings in quotes always work.

String variables (stringVar="Hello") seem to allow themselves to be styled by STYLE set before the paragraph, ignoring the style directives within the paragraph.

String parameters (Create a string parameter, sParam) are worse, they ignore all the styles, using a default style of some sort. If I turn the string parameter's data into a variable (stringVar=sParam), it's still all wrong. If I add to he variable (stringVar=sParam+"Hello"), it acts like a variable as above.

It looks broken to me. But you can build a PARAGRAPH from variables as long as you only need one style, and you can use parameters if you convert them to variables.
James Murray

Archicad 27 • Rill Architects • macOS • OnLand.info
Anonymous
Not applicable
Thanks for testing James! I had already torn almost all my hair out trying to figure this
The reason why I got involved with the Richtext with its intricacies is that I am trying to parse an object imported from DWG.

The DWG importer behaves in two totally different ways if you import a DWG with attribute definitions as a GDL object or as editable objects to the current drawing.

The imported object comes with the attribute definitions as parameters in the parameter list, and text2 objects referencing the parameters in the 2D script, and the rest of the geometry as a 2D fragment.

If I import it into my drawing before converting the entities into a GDL object, the result is that all the text is converted into richtext objects instead. In my case I really don't see the point - the richtext with all its paragraph and textblock definitions takes about 10 times the amount of code.

Thanks again

Anssi
Anonymous
Not applicable
Thanks James. I thought it was broken. Glad to have both confirmation and workaround. It didn't occur to me to assign the parameter value to a variable.
Anonymous
Not applicable
This should work too:
stringVar=""+sParam
Anonymous
Not applicable
I finally got it to work. Thanks everyone for the input. I have also discovered that it is possible to set styles and pens for variables within the paragraph. The trick is to add the null string in-line rather than beforehand. For example:
drwg_name		= AC_DrawingName

DEFINE STYLE{2} "title_style" "Arial", 5, 0

PARAGRAPH "title_paragraph" 1, 0, 0, 0, 1
	SET STYLE "title_style"
	PEN 7
	drwg_name + ""
ENDPARAGRAPH
In fact I was unable to get it to work by adding the null string outside of the paragraph definition. But I have found that it works with the parameter name as well.