
! script name: vproperty.d/linetypeent
! var_topic: assign linetype to an element or group

!A
!A NAME:
!A
!A 	Assign Linetype    --- VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a linetype to be assigned to an element or group.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT LINE TYPE: The LINE TYPES options selection box will
!B 		automatically appear to allow the selection of a linetype.
!B
!B	PICK GROUP:  Single, New linetype: Pick the group or switch to single
!B		element pick, or select a new linetype.
!B
!B	PICK ELEMENT:  Group, New linetype: Pick the element or switch to
!B		group pick, or select a new linetype.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: assign linetype ")

DIM Destination$[256]
DIM Answer$[256]
DIM Namelist$[1000]
DIM Title$[256]
DIM Label$[256]
DIM Element$[256]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

Start:!
ActivateUndo
Title$="LINE TYPES"
Label$="LINE TYPE SELECTED"
Namelist$=          "1  ________________________,"
Namelist$=Namelist$&"2  . . . . . . . . . . . . ,"
Namelist$=Namelist$&"3  .   .   .   .   .   .  .,"
Namelist$=Namelist$&"4  ........................,"
Namelist$=Namelist$&"5  __ __ __ __ __ __ __ __ ,"
Namelist$=Namelist$&"6  __ _  __ _  __ _ __ _ __,"
Namelist$=Namelist$&"7  __ .  __ .  __ . __ . __,"
Namelist$=Namelist$&"8  __ .. __ .. __ .. __ .. ,"
Namelist$=Namelist$&"9  WIDE ___________________,"
Namelist$=Namelist$&"10 XWIDE __________________,"
Namelist$=Namelist$&"11 XXWIDE _________________,"
Namelist$=Namelist$&"12 WIDE __ __ __ __ __ __ _,"
Namelist$=Namelist$&"13 ____  _____ _____ _____ ,"
Namelist$=Namelist$&"14 ____ . _____ . _____ . _,"
Namelist$=Namelist$&"15 ____ .. _____ .. _____ .,"
Namelist$=Namelist$&"16 ___ ___ _ _ ___ ___ _ _ ,"
Namelist$=Namelist$&"17 ___ ___ .. ___ ___ ..   ,"
Namelist$=Namelist$&"18 ____ ____ _ _ ____ ____ _ _,"
Namelist$=Namelist$&"19 _____ ... _____ ... ,"

Stat=GeneralListBox(Title$,Label$,Namelist$)
Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT LINE TYPE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "CANCEL" THEN Leave
Ltype= VAL(Answer$)
IF Ltype<1 OR Ltype> 19 THEN Start
LowerSelectBox


Pick_entity: !
ActivateUndo
Stat=ChangeLabelStr("Status","Line type = "&VAL$(Ltype))
Stat=SetInputFormat("n4a1",",N,G,")
Element=PickEntity("PICK ELEMENT:   Group, New linetype ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="G" THEN Pick_group
IF Answer$="N" THEN Start
IF NOT ValidDependency(Element) THEN Pick_entity
Stat=EntityNameCheck(Element,Element$)
Picked_group=0
GOSUB Make_record
GOTO Pick_entity

Pick_group: !
ActivateUndo
Stat=ChangeLabelStr("Status","Line type = "&VAL$(Ltype))
Stat=SetInputFormat("n4a1",",N,S,")
Group=PickGroupEnt("PICK GROUP:   Single, Name",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="S" THEN Pick_entity
IF Answer$="N" THEN 
	GOSUB Get_named_grp
END IF
IF NOT ValidDependency(Group) THEN Pick_group
Stat=EntityNameCheck(Group,Element$)
Picked_group=1
GOSUB Make_record
GOTO Pick_group

Get_named_grp:!
Stat=ListGrpNames("GROUP NAMES","selected group","",0)
IF Stat=1 THEN Leave
Stat=SetInputFormat("a99","")
Stat=GetValue("GROUP NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Group=FindNamedGrp(Answer$)
IF NOT ValidGeometry(Group) THEN Get_named_grp
Stat=SetInputFormat("n4","")
LowerSelectBox
RETURN

Make_record:!
ActivateUndo
IF Picked_group THEN
	Stat= AdvanceUndoNumber("line type group")
	Stat= AddGroupToUndo(WsUBModifyMode,Group,1,WsTrue)
ELSE
	Stat= AdvanceUndoNumber("line type entity")
	Stat= AddItemToUndo(WsUBModifyMode,Element)
END IF

RecordFunctionOn
Stat=RecordDescr("PROPERTY: Line type ")
V1=FreeParameter("Line type",ltype)
Stat=SetLineType(Element$,V1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
RETURN


Leave:!
LowerSelectBox
Stat=ChangeLabelStr("Status"," ")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
